mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[EarlyCSE] add tests for swapped abs/nabs; NFC
llvm-svn: 320647
This commit is contained in:
parent
870a9f4a4e
commit
1f0e780564
@ -218,3 +218,41 @@ define i8 @smax_nsw(i8 %a, i8 %b) {
|
||||
ret i8 %r
|
||||
}
|
||||
|
||||
define i8 @abs_swapped(i8 %a) {
|
||||
; CHECK-LABEL: @abs_swapped(
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, %a
|
||||
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, 0
|
||||
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, 0
|
||||
; CHECK-NEXT: [[M1:%.*]] = select i1 [[CMP1]], i8 %a, i8 [[NEG]]
|
||||
; CHECK-NEXT: [[M2:%.*]] = select i1 [[CMP2]], i8 [[NEG]], i8 %a
|
||||
; CHECK-NEXT: [[R:%.*]] = or i8 [[M2]], [[M1]]
|
||||
; CHECK-NEXT: ret i8 [[R]]
|
||||
;
|
||||
%neg = sub i8 0, %a
|
||||
%cmp1 = icmp sgt i8 %a, 0
|
||||
%cmp2 = icmp slt i8 %a, 0
|
||||
%m1 = select i1 %cmp1, i8 %a, i8 %neg
|
||||
%m2 = select i1 %cmp2, i8 %neg, i8 %a
|
||||
%r = or i8 %m2, %m1
|
||||
ret i8 %r
|
||||
}
|
||||
|
||||
define i8 @nabs_swapped(i8 %a) {
|
||||
; CHECK-LABEL: @nabs_swapped(
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, %a
|
||||
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, 0
|
||||
; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, 0
|
||||
; CHECK-NEXT: [[M1:%.*]] = select i1 [[CMP1]], i8 %a, i8 [[NEG]]
|
||||
; CHECK-NEXT: [[M2:%.*]] = select i1 [[CMP2]], i8 [[NEG]], i8 %a
|
||||
; CHECK-NEXT: [[R:%.*]] = xor i8 [[M2]], [[M1]]
|
||||
; CHECK-NEXT: ret i8 [[R]]
|
||||
;
|
||||
%neg = sub i8 0, %a
|
||||
%cmp1 = icmp slt i8 %a, 0
|
||||
%cmp2 = icmp sgt i8 %a, 0
|
||||
%m1 = select i1 %cmp1, i8 %a, i8 %neg
|
||||
%m2 = select i1 %cmp2, i8 %neg, i8 %a
|
||||
%r = xor i8 %m2, %m1
|
||||
ret i8 %r
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user