xref: /llvm-project/llvm/test/CodeGen/X86/GlobalISel/lshr-scalar.ll (revision 373c343a77a7afaa07179db1754a52b620dfaf2e)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
3
4define i64 @test_lshr_i64(i64 %arg1, i64 %arg2) {
5; X64-LABEL: test_lshr_i64:
6; X64:       # %bb.0:
7; X64-NEXT:    movq %rdi, %rax
8; X64-NEXT:    movq %rsi, %rcx
9; X64-NEXT:    # kill: def $cl killed $cl killed $rcx
10; X64-NEXT:    shrq %cl, %rax
11; X64-NEXT:    retq
12  %res = lshr i64 %arg1, %arg2
13  ret i64 %res
14}
15
16define i64 @test_lshr_i64_imm(i64 %arg1) {
17; X64-LABEL: test_lshr_i64_imm:
18; X64:       # %bb.0:
19; X64-NEXT:    movq %rdi, %rax
20; X64-NEXT:    shrq $5, %rax
21; X64-NEXT:    retq
22  %res = lshr i64 %arg1, 5
23  ret i64 %res
24}
25
26define i64 @test_lshr_i64_imm1(i64 %arg1) {
27; X64-LABEL: test_lshr_i64_imm1:
28; X64:       # %bb.0:
29; X64-NEXT:    movq %rdi, %rax
30; X64-NEXT:    shrq %rax
31; X64-NEXT:    retq
32  %res = lshr i64 %arg1, 1
33  ret i64 %res
34}
35
36define i32 @test_lshr_i32(i32 %arg1, i32 %arg2) {
37; X64-LABEL: test_lshr_i32:
38; X64:       # %bb.0:
39; X64-NEXT:    movl %edi, %eax
40; X64-NEXT:    movl %esi, %ecx
41; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
42; X64-NEXT:    shrl %cl, %eax
43; X64-NEXT:    retq
44  %res = lshr i32 %arg1, %arg2
45  ret i32 %res
46}
47
48define i32 @test_lshr_i32_imm(i32 %arg1) {
49; X64-LABEL: test_lshr_i32_imm:
50; X64:       # %bb.0:
51; X64-NEXT:    movl %edi, %eax
52; X64-NEXT:    shrl $5, %eax
53; X64-NEXT:    retq
54  %res = lshr i32 %arg1, 5
55  ret i32 %res
56}
57
58define i32 @test_lshr_i32_imm1(i32 %arg1) {
59; X64-LABEL: test_lshr_i32_imm1:
60; X64:       # %bb.0:
61; X64-NEXT:    movl %edi, %eax
62; X64-NEXT:    shrl %eax
63; X64-NEXT:    retq
64  %res = lshr i32 %arg1, 1
65  ret i32 %res
66}
67
68define i16 @test_lshr_i16(i32 %arg1, i32 %arg2) {
69; X64-LABEL: test_lshr_i16:
70; X64:       # %bb.0:
71; X64-NEXT:    movl %edi, %eax
72; X64-NEXT:    movl %esi, %ecx
73; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
74; X64-NEXT:    shrw %cl, %ax
75; X64-NEXT:    # kill: def $ax killed $ax killed $eax
76; X64-NEXT:    retq
77  %a = trunc i32 %arg1 to i16
78  %a2 = trunc i32 %arg2 to i16
79  %res = lshr i16 %a, %a2
80  ret i16 %res
81}
82
83define i16 @test_lshr_i16_imm(i32 %arg1) {
84; X64-LABEL: test_lshr_i16_imm:
85; X64:       # %bb.0:
86; X64-NEXT:    movl %edi, %eax
87; X64-NEXT:    shrw $5, %ax
88; X64-NEXT:    # kill: def $ax killed $ax killed $eax
89; X64-NEXT:    retq
90  %a = trunc i32 %arg1 to i16
91  %res = lshr i16 %a, 5
92  ret i16 %res
93}
94
95define i16 @test_lshr_i16_imm1(i32 %arg1) {
96; X64-LABEL: test_lshr_i16_imm1:
97; X64:       # %bb.0:
98; X64-NEXT:    movl %edi, %eax
99; X64-NEXT:    shrw %ax
100; X64-NEXT:    # kill: def $ax killed $ax killed $eax
101; X64-NEXT:    retq
102  %a = trunc i32 %arg1 to i16
103  %res = lshr i16 %a, 1
104  ret i16 %res
105}
106
107define i8 @test_lshr_i8(i32 %arg1, i32 %arg2) {
108; X64-LABEL: test_lshr_i8:
109; X64:       # %bb.0:
110; X64-NEXT:    movl %edi, %eax
111; X64-NEXT:    movl %esi, %ecx
112; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
113; X64-NEXT:    shrb %cl, %al
114; X64-NEXT:    # kill: def $al killed $al killed $eax
115; X64-NEXT:    retq
116  %a = trunc i32 %arg1 to i8
117  %a2 = trunc i32 %arg2 to i8
118  %res = lshr i8 %a, %a2
119  ret i8 %res
120}
121
122define i8 @test_lshr_i8_imm(i32 %arg1) {
123; X64-LABEL: test_lshr_i8_imm:
124; X64:       # %bb.0:
125; X64-NEXT:    movl %edi, %eax
126; X64-NEXT:    shrb $5, %al
127; X64-NEXT:    # kill: def $al killed $al killed $eax
128; X64-NEXT:    retq
129  %a = trunc i32 %arg1 to i8
130  %res = lshr i8 %a, 5
131  ret i8 %res
132}
133
134define i8 @test_lshr_i8_imm1(i32 %arg1) {
135; X64-LABEL: test_lshr_i8_imm1:
136; X64:       # %bb.0:
137; X64-NEXT:    movl %edi, %eax
138; X64-NEXT:    shrb %al
139; X64-NEXT:    # kill: def $al killed $al killed $eax
140; X64-NEXT:    retq
141  %a = trunc i32 %arg1 to i8
142  %res = lshr i8 %a, 1
143  ret i8 %res
144}
145
146define i1 @test_lshr_i1(i32 %arg1, i32 %arg2) {
147; X64-LABEL: test_lshr_i1:
148; X64:       # %bb.0:
149; X64-NEXT:    movl %edi, %eax
150; X64-NEXT:    movl %esi, %ecx
151; X64-NEXT:    andb $1, %al
152; X64-NEXT:    andb $1, %cl
153; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
154; X64-NEXT:    shrb %cl, %al
155; X64-NEXT:    # kill: def $al killed $al killed $eax
156; X64-NEXT:    retq
157  %a = trunc i32 %arg1 to i1
158  %a2 = trunc i32 %arg2 to i1
159  %res = lshr i1 %a, %a2
160  ret i1 %res
161}
162
163define i1 @test_lshr_i1_imm1(i32 %arg1) {
164; X64-LABEL: test_lshr_i1_imm1:
165; X64:       # %bb.0:
166; X64-NEXT:    movl %edi, %eax
167; X64-NEXT:    andb $1, %al
168; X64-NEXT:    shrb %al
169; X64-NEXT:    # kill: def $al killed $al killed $eax
170; X64-NEXT:    retq
171  %a = trunc i32 %arg1 to i1
172  %res = lshr i1 %a, 1
173  ret i1 %res
174}
175