llvm.org GIT mirror llvm / 4631d6d
[EarlyCSE] add tests for swapped abs/nabs; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320647 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 9 months ago
1 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
217217 ret i8 %r
218218 }
219219
220 define i8 @abs_swapped(i8 %a) {
221 ; CHECK-LABEL: @abs_swapped(
222 ; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, %a
223 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, 0
224 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, 0
225 ; CHECK-NEXT: [[M1:%.*]] = select i1 [[CMP1]], i8 %a, i8 [[NEG]]
226 ; CHECK-NEXT: [[M2:%.*]] = select i1 [[CMP2]], i8 [[NEG]], i8 %a
227 ; CHECK-NEXT: [[R:%.*]] = or i8 [[M2]], [[M1]]
228 ; CHECK-NEXT: ret i8 [[R]]
229 ;
230 %neg = sub i8 0, %a
231 %cmp1 = icmp sgt i8 %a, 0
232 %cmp2 = icmp slt i8 %a, 0
233 %m1 = select i1 %cmp1, i8 %a, i8 %neg
234 %m2 = select i1 %cmp2, i8 %neg, i8 %a
235 %r = or i8 %m2, %m1
236 ret i8 %r
237 }
238
239 define i8 @nabs_swapped(i8 %a) {
240 ; CHECK-LABEL: @nabs_swapped(
241 ; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, %a
242 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, 0
243 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, 0
244 ; CHECK-NEXT: [[M1:%.*]] = select i1 [[CMP1]], i8 %a, i8 [[NEG]]
245 ; CHECK-NEXT: [[M2:%.*]] = select i1 [[CMP2]], i8 [[NEG]], i8 %a
246 ; CHECK-NEXT: [[R:%.*]] = xor i8 [[M2]], [[M1]]
247 ; CHECK-NEXT: ret i8 [[R]]
248 ;
249 %neg = sub i8 0, %a
250 %cmp1 = icmp slt i8 %a, 0
251 %cmp2 = icmp sgt i8 %a, 0
252 %m1 = select i1 %cmp1, i8 %a, i8 %neg
253 %m2 = select i1 %cmp2, i8 %neg, i8 %a
254 %r = xor i8 %m2, %m1
255 ret i8 %r
256 }
257