llvm.org GIT mirror llvm / bae951d
[x86] add tests to show missed min/max vector codegen (PR31693) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292640 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 3 years ago
1 changed file(s) with 73 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
12 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s
23
1011 ; CHECK-NEXT: vpxor %xmm1, %xmm0, %xmm0
1112 ; CHECK-NEXT: vpminsd %xmm1, %xmm0, %xmm0
1213 ; CHECK-NEXT: retq
13 ;
1414 %not_x = xor <4 x i32> %x,
1515 %cmp = icmp sgt <4 x i32> %x, zeroinitializer
1616 %sel = select <4 x i1> %cmp, <4 x i32> %not_x, <4 x i32>
2424 ; CHECK-NEXT: vpxor %xmm1, %xmm0, %xmm0
2525 ; CHECK-NEXT: vpminsd %xmm1, %xmm0, %xmm0
2626 ; CHECK-NEXT: retq
27 ;
2827 %not_x = xor <4 x i32> %x,
2928 %cmp = icmp slt <4 x i32> %x, zeroinitializer
3029 %sel = select <4 x i1> %cmp, <4 x i32> , <4 x i32> %not_x
4039 ; CHECK-NEXT: vpxor %xmm1, %xmm1, %xmm1
4140 ; CHECK-NEXT: vpminsd %xmm1, %xmm0, %xmm0
4241 ; CHECK-NEXT: retq
43 ;
4442 %sub = sub nsw <4 x i32> %x, %y
4543 %cmp = icmp sgt <4 x i32> %x, %y
4644 %sel = select <4 x i1> %cmp, <4 x i32> zeroinitializer, <4 x i32> %sub
5654 ; CHECK-NEXT: vpxor %xmm1, %xmm1, %xmm1
5755 ; CHECK-NEXT: vpminsd %xmm1, %xmm0, %xmm0
5856 ; CHECK-NEXT: retq
59 ;
6057 %sub = sub nsw <4 x i32> %x, %y
6158 %cmp = icmp slt <4 x i32> %x, %y
6259 %sel = select <4 x i1> %cmp, <4 x i32> %sub, <4 x i32> zeroinitializer
7067 ; CHECK-NEXT: vpxor %xmm1, %xmm0, %xmm0
7168 ; CHECK-NEXT: vpmaxsd %xmm1, %xmm0, %xmm0
7269 ; CHECK-NEXT: retq
73 ;
7470 %not_x = xor <4 x i32> %x,
7571 %cmp = icmp slt <4 x i32> %x, zeroinitializer
7672 %sel = select <4 x i1> %cmp, <4 x i32> %not_x, <4 x i32>
8480 ; CHECK-NEXT: vpxor %xmm1, %xmm0, %xmm0
8581 ; CHECK-NEXT: vpmaxsd %xmm1, %xmm0, %xmm0
8682 ; CHECK-NEXT: retq
87 ;
8883 %not_x = xor <4 x i32> %x,
8984 %cmp = icmp sgt <4 x i32> %x, zeroinitializer
9085 %sel = select <4 x i1> %cmp, <4 x i32> , <4 x i32> %not_x
10095 ; CHECK-NEXT: vpxor %xmm1, %xmm1, %xmm1
10196 ; CHECK-NEXT: vpmaxsd %xmm1, %xmm0, %xmm0
10297 ; CHECK-NEXT: retq
103 ;
10498 %sub = sub nsw <4 x i32> %x, %y
10599 %cmp = icmp slt <4 x i32> %x, %y
106100 %sel = select <4 x i1> %cmp, <4 x i32> zeroinitializer, <4 x i32> %sub
116110 ; CHECK-NEXT: vpxor %xmm1, %xmm1, %xmm1
117111 ; CHECK-NEXT: vpmaxsd %xmm1, %xmm0, %xmm0
118112 ; CHECK-NEXT: retq
119 ;
120113 %sub = sub nsw <4 x i32> %x, %y
121114 %cmp = icmp sgt <4 x i32> %x, %y
122115 %sel = select <4 x i1> %cmp, <4 x i32> %sub, <4 x i32> zeroinitializer
128121 ; CHECK: # BB#0:
129122 ; CHECK-NEXT: vpmaxud {{.*}}(%rip), %xmm0, %xmm0
130123 ; CHECK-NEXT: retq
131 ;
132124 %cmp = icmp slt <4 x i32> %x, zeroinitializer
133125 %sel = select <4 x i1> %cmp, <4 x i32> %x, <4 x i32>
134126 ret <4 x i32> %sel
139131 ; CHECK: # BB#0:
140132 ; CHECK-NEXT: vpmaxud {{.*}}(%rip), %xmm0, %xmm0
141133 ; CHECK-NEXT: retq
142 ;
143134 %cmp = icmp sgt <4 x i32> %x,
144135 %sel = select <4 x i1> %cmp, <4 x i32> , <4 x i32> %x
145136 ret <4 x i32> %sel
150141 ; CHECK: # BB#0:
151142 ; CHECK-NEXT: vpminud {{.*}}(%rip), %xmm0, %xmm0
152143 ; CHECK-NEXT: retq
153 ;
154144 %cmp = icmp slt <4 x i32> %x, zeroinitializer
155145 %sel = select <4 x i1> %cmp, <4 x i32> , <4 x i32> %x
156146 ret <4 x i32> %sel
161151 ; CHECK: # BB#0:
162152 ; CHECK-NEXT: vpminud {{.*}}(%rip), %xmm0, %xmm0
163153 ; CHECK-NEXT: retq
164 ;
165154 %cmp = icmp sgt <4 x i32> %x,
166155 %sel = select <4 x i1> %cmp, <4 x i32> %x, <4 x i32>
167156 ret <4 x i32> %sel
168157 }
169158
159 ; The next 4 tests are value clamping with constants:
160 ; https://llvm.org/bugs/show_bug.cgi?id=31693
161
162 ; (X SMAX(SMIN(X, C2), C1)
163
164 define <4 x i32> @clamp_signed1(<4 x i32> %x) {
165 ; CHECK-LABEL: clamp_signed1:
166 ; CHECK: # BB#0:
167 ; CHECK-NEXT: vpminsd {{.*}}(%rip), %xmm0, %xmm1
168 ; CHECK-NEXT: vmovdqa {{.*#+}} xmm2 = [15,15,15,15]
169 ; CHECK-NEXT: vpcmpgtd %xmm0, %xmm2, %xmm0
170 ; CHECK-NEXT: vblendvps %xmm0, %xmm2, %xmm1, %xmm0
171 ; CHECK-NEXT: retq
172 %cmp2 = icmp slt <4 x i32> %x,
173 %min = select <4 x i1> %cmp2, <4 x i32> %x, <4 x i32>
174 %cmp1 = icmp slt <4 x i32> %x,
175 %r = select <4 x i1> %cmp1, <4 x i32>, <4 x i32> %min
176 ret <4 x i32> %r
177 }
178
179 ; (X >s C1) ? C1 : SMAX(X, C2) ==> SMIN(SMAX(X, C2), C1)
180
181 define <4 x i32> @clamp_signed2(<4 x i32> %x) {
182 ; CHECK-LABEL: clamp_signed2:
183 ; CHECK: # BB#0:
184 ; CHECK-NEXT: vpmaxsd {{.*}}(%rip), %xmm0, %xmm1
185 ; CHECK-NEXT: vmovdqa {{.*#+}} xmm2 = [255,255,255,255]
186 ; CHECK-NEXT: vpcmpgtd %xmm2, %xmm0, %xmm0
187 ; CHECK-NEXT: vblendvps %xmm0, %xmm2, %xmm1, %xmm0
188 ; CHECK-NEXT: retq
189 %cmp2 = icmp sgt <4 x i32> %x,
190 %max = select <4 x i1> %cmp2, <4 x i32> %x, <4 x i32>
191 %cmp1 = icmp sgt <4 x i32> %x,
192 %r = select <4 x i1> %cmp1, <4 x i32>, <4 x i32> %max
193 ret <4 x i32> %r
194 }
195
196 ; (X UMAX(UMIN(X, C2), C1)
197
198 define <4 x i32> @clamp_unsigned1(<4 x i32> %x) {
199 ; CHECK-LABEL: clamp_unsigned1:
200 ; CHECK: # BB#0:
201 ; CHECK-NEXT: vpminud {{.*}}(%rip), %xmm0, %xmm1
202 ; CHECK-NEXT: vpxor {{.*}}(%rip), %xmm0, %xmm0
203 ; CHECK-NEXT: vmovdqa {{.*#+}} xmm2 = [2147483663,2147483663,2147483663,2147483663]
204 ; CHECK-NEXT: vpcmpgtd %xmm0, %xmm2, %xmm0
205 ; CHECK-NEXT: vblendvps %xmm0, {{.*}}(%rip), %xmm1, %xmm0
206 ; CHECK-NEXT: retq
207 %cmp2 = icmp ult <4 x i32> %x,
208 %min = select <4 x i1> %cmp2, <4 x i32> %x, <4 x i32>
209 %cmp1 = icmp ult <4 x i32> %x,
210 %r = select <4 x i1> %cmp1, <4 x i32>, <4 x i32> %min
211 ret <4 x i32> %r
212 }
213
214 ; (X >u C1) ? C1 : UMAX(X, C2) ==> UMIN(UMAX(X, C2), C1)
215
216 define <4 x i32> @clamp_unsigned2(<4 x i32> %x) {
217 ; CHECK-LABEL: clamp_unsigned2:
218 ; CHECK: # BB#0:
219 ; CHECK-NEXT: vpmaxud {{.*}}(%rip), %xmm0, %xmm1
220 ; CHECK-NEXT: vpxor {{.*}}(%rip), %xmm0, %xmm0
221 ; CHECK-NEXT: vpcmpgtd {{.*}}(%rip), %xmm0, %xmm0
222 ; CHECK-NEXT: vblendvps %xmm0, {{.*}}(%rip), %xmm1, %xmm0
223 ; CHECK-NEXT: retq
224 %cmp2 = icmp ugt <4 x i32> %x,
225 %max = select <4 x i1> %cmp2, <4 x i32> %x, <4 x i32>
226 %cmp1 = icmp ugt <4 x i32> %x,
227 %r = select <4 x i1> %cmp1, <4 x i32>, <4 x i32> %max
228 ret <4 x i32> %r
229 }
230