1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=CHECK,SSE
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX1
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX2
6 define i32 @shl48sar47(i64 %a) #0 {
7 ; CHECK-LABEL: shl48sar47:
9 ; CHECK-NEXT: movswl %di, %eax
10 ; CHECK-NEXT: addl %eax, %eax
13 %2 = ashr exact i64 %1, 47
14 %3 = trunc i64 %2 to i32
18 define i32 @shl48sar49(i64 %a) #0 {
19 ; CHECK-LABEL: shl48sar49:
21 ; CHECK-NEXT: movswq %di, %rax
22 ; CHECK-NEXT: shrq %rax
23 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
26 %2 = ashr exact i64 %1, 49
27 %3 = trunc i64 %2 to i32
31 define i32 @shl56sar55(i64 %a) #0 {
32 ; CHECK-LABEL: shl56sar55:
34 ; CHECK-NEXT: movsbl %dil, %eax
35 ; CHECK-NEXT: addl %eax, %eax
38 %2 = ashr exact i64 %1, 55
39 %3 = trunc i64 %2 to i32
43 define i32 @shl56sar57(i64 %a) #0 {
44 ; CHECK-LABEL: shl56sar57:
46 ; CHECK-NEXT: movsbq %dil, %rax
47 ; CHECK-NEXT: shrq %rax
48 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
51 %2 = ashr exact i64 %1, 57
52 %3 = trunc i64 %2 to i32
56 define i8 @all_sign_bit_ashr(i8 %x) {
57 ; CHECK-LABEL: all_sign_bit_ashr:
59 ; CHECK-NEXT: movl %edi, %eax
60 ; CHECK-NEXT: andb $1, %al
61 ; CHECK-NEXT: negb %al
62 ; CHECK-NEXT: # kill: def $al killed $al killed $eax
66 %sar = ashr i8 %neg, 6
70 define <4 x i32> @all_sign_bit_ashr_vec0(<4 x i32> %x) {
71 ; SSE-LABEL: all_sign_bit_ashr_vec0:
73 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
74 ; SSE-NEXT: pxor %xmm1, %xmm1
75 ; SSE-NEXT: psubd %xmm0, %xmm1
76 ; SSE-NEXT: movdqa %xmm1, %xmm0
79 ; AVX1-LABEL: all_sign_bit_ashr_vec0:
81 ; AVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
82 ; AVX1-NEXT: vpxor %xmm1, %xmm1, %xmm1
83 ; AVX1-NEXT: vpsubd %xmm0, %xmm1, %xmm0
86 ; AVX2-LABEL: all_sign_bit_ashr_vec0:
88 ; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm1 = [1,1,1,1]
89 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
90 ; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1
91 ; AVX2-NEXT: vpsubd %xmm0, %xmm1, %xmm0
93 %and = and <4 x i32> %x, <i32 1, i32 1, i32 1 , i32 1>
94 %neg = sub <4 x i32> zeroinitializer, %and
95 %sar = ashr <4 x i32> %neg, <i32 1, i32 31, i32 5, i32 0>
99 define <4 x i32> @all_sign_bit_ashr_vec1(<4 x i32> %x) {
100 ; SSE-LABEL: all_sign_bit_ashr_vec1:
102 ; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm0[0,0,0,0]
103 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
104 ; SSE-NEXT: pxor %xmm0, %xmm0
105 ; SSE-NEXT: psubd %xmm1, %xmm0
108 ; AVX1-LABEL: all_sign_bit_ashr_vec1:
110 ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,0]
111 ; AVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
112 ; AVX1-NEXT: vpxor %xmm1, %xmm1, %xmm1
113 ; AVX1-NEXT: vpsubd %xmm0, %xmm1, %xmm0
116 ; AVX2-LABEL: all_sign_bit_ashr_vec1:
118 ; AVX2-NEXT: vpbroadcastd %xmm0, %xmm0
119 ; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm1 = [1,1,1,1]
120 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
121 ; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1
122 ; AVX2-NEXT: vpsubd %xmm0, %xmm1, %xmm0
124 %and = and <4 x i32> %x, <i32 1, i32 1, i32 1 , i32 1>
125 %sub = sub <4 x i32> <i32 0, i32 1, i32 2, i32 3>, %and
126 %shf = shufflevector <4 x i32> %sub, <4 x i32> undef, <4 x i32> zeroinitializer
127 %sar = ashr <4 x i32> %shf, <i32 1, i32 31, i32 5, i32 0>
131 define <4 x i32> @all_sign_bit_ashr_vec2(<4 x i32> %x) {
132 ; SSE-LABEL: all_sign_bit_ashr_vec2:
134 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
135 ; SSE-NEXT: pcmpeqd %xmm1, %xmm1
136 ; SSE-NEXT: paddd %xmm1, %xmm0
139 ; AVX1-LABEL: all_sign_bit_ashr_vec2:
141 ; AVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
142 ; AVX1-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1
143 ; AVX1-NEXT: vpaddd %xmm1, %xmm0, %xmm0
146 ; AVX2-LABEL: all_sign_bit_ashr_vec2:
148 ; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm1 = [1,1,1,1]
149 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
150 ; AVX2-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1
151 ; AVX2-NEXT: vpaddd %xmm1, %xmm0, %xmm0
153 %and = and <4 x i32> %x, <i32 1, i32 1, i32 1 , i32 1>
154 %add = add <4 x i32> %and, <i32 -1, i32 -1, i32 -1, i32 -1>
155 %sar = ashr <4 x i32> %add, <i32 1, i32 31, i32 5, i32 0>
159 define <4 x i32> @all_sign_bit_ashr_vec3(<4 x i32> %x) {
160 ; SSE-LABEL: all_sign_bit_ashr_vec3:
162 ; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm0[0,0,0,0]
163 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
164 ; SSE-NEXT: pcmpeqd %xmm0, %xmm0
165 ; SSE-NEXT: paddd %xmm1, %xmm0
168 ; AVX1-LABEL: all_sign_bit_ashr_vec3:
170 ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,0]
171 ; AVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
172 ; AVX1-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1
173 ; AVX1-NEXT: vpaddd %xmm1, %xmm0, %xmm0
176 ; AVX2-LABEL: all_sign_bit_ashr_vec3:
178 ; AVX2-NEXT: vpbroadcastd %xmm0, %xmm0
179 ; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm1 = [1,1,1,1]
180 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
181 ; AVX2-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1
182 ; AVX2-NEXT: vpaddd %xmm1, %xmm0, %xmm0
184 %and = and <4 x i32> %x, <i32 1, i32 1, i32 1 , i32 1>
185 %add = add <4 x i32> %and, <i32 -1, i32 1, i32 2, i32 3>
186 %shf = shufflevector <4 x i32> %add, <4 x i32> undef, <4 x i32> zeroinitializer
187 %sar = ashr <4 x i32> %shf, <i32 1, i32 31, i32 5, i32 0>
191 attributes #0 = { nounwind }