forked from OSchip/llvm-project
[InstCombine] add more tests for max(~a, ~b) and PR35834; NFC
llvm-svn: 321935
This commit is contained in:
parent
5a48aef3f0
commit
f7e775291e
|
@ -43,6 +43,70 @@ define i32 @compute_min_2(i32 %x, i32 %y) {
|
|||
ret i32 %min
|
||||
}
|
||||
|
||||
declare void @extra_use(i8)
|
||||
define i8 @umin_not_1_extra_use(i8 %x, i8 %y) {
|
||||
; CHECK-LABEL: @umin_not_1_extra_use(
|
||||
; CHECK-NEXT: [[NX:%.*]] = xor i8 %x, -1
|
||||
; CHECK-NEXT: [[NY:%.*]] = xor i8 %y, -1
|
||||
; CHECK-NEXT: [[CMPXY:%.*]] = icmp ult i8 [[NX]], [[NY]]
|
||||
; CHECK-NEXT: [[MINXY:%.*]] = select i1 [[CMPXY]], i8 [[NX]], i8 [[NY]]
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[NX]])
|
||||
; CHECK-NEXT: ret i8 [[MINXY]]
|
||||
;
|
||||
%nx = xor i8 %x, -1
|
||||
%ny = xor i8 %y, -1
|
||||
%cmpxy = icmp ult i8 %nx, %ny
|
||||
%minxy = select i1 %cmpxy, i8 %nx, i8 %ny
|
||||
call void @extra_use(i8 %nx)
|
||||
ret i8 %minxy
|
||||
}
|
||||
|
||||
define i8 @umin_not_2_extra_use(i8 %x, i8 %y) {
|
||||
; CHECK-LABEL: @umin_not_2_extra_use(
|
||||
; CHECK-NEXT: [[NX:%.*]] = xor i8 %x, -1
|
||||
; CHECK-NEXT: [[NY:%.*]] = xor i8 %y, -1
|
||||
; CHECK-NEXT: [[CMPXY:%.*]] = icmp ult i8 [[NX]], [[NY]]
|
||||
; CHECK-NEXT: [[MINXY:%.*]] = select i1 [[CMPXY]], i8 [[NX]], i8 [[NY]]
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[NX]])
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[NY]])
|
||||
; CHECK-NEXT: ret i8 [[MINXY]]
|
||||
;
|
||||
%nx = xor i8 %x, -1
|
||||
%ny = xor i8 %y, -1
|
||||
%cmpxy = icmp ult i8 %nx, %ny
|
||||
%minxy = select i1 %cmpxy, i8 %nx, i8 %ny
|
||||
call void @extra_use(i8 %nx)
|
||||
call void @extra_use(i8 %ny)
|
||||
ret i8 %minxy
|
||||
}
|
||||
|
||||
; PR35834 - https://bugs.llvm.org/show_bug.cgi?id=35834
|
||||
|
||||
define i8 @umin3_not(i8 %x, i8 %y, i8 %z) {
|
||||
; CHECK-LABEL: @umin3_not(
|
||||
; CHECK-NEXT: [[NX:%.*]] = xor i8 %x, -1
|
||||
; CHECK-NEXT: [[NY:%.*]] = xor i8 %y, -1
|
||||
; CHECK-NEXT: [[NZ:%.*]] = xor i8 %z, -1
|
||||
; CHECK-NEXT: [[CMPYX:%.*]] = icmp ult i8 %y, %x
|
||||
; CHECK-NEXT: [[CMPXZ:%.*]] = icmp ult i8 [[NX]], [[NZ]]
|
||||
; CHECK-NEXT: [[MINXZ:%.*]] = select i1 [[CMPXZ]], i8 [[NX]], i8 [[NZ]]
|
||||
; CHECK-NEXT: [[CMPYZ:%.*]] = icmp ult i8 [[NY]], [[NZ]]
|
||||
; CHECK-NEXT: [[MINYZ:%.*]] = select i1 [[CMPYZ]], i8 [[NY]], i8 [[NZ]]
|
||||
; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPYX]], i8 [[MINXZ]], i8 [[MINYZ]]
|
||||
; CHECK-NEXT: ret i8 [[R]]
|
||||
;
|
||||
%nx = xor i8 %x, -1
|
||||
%ny = xor i8 %y, -1
|
||||
%nz = xor i8 %z, -1
|
||||
%cmpyx = icmp ult i8 %y, %x
|
||||
%cmpxz = icmp ult i8 %nx, %nz
|
||||
%minxz = select i1 %cmpxz, i8 %nx, i8 %nz
|
||||
%cmpyz = icmp ult i8 %ny, %nz
|
||||
%minyz = select i1 %cmpyz, i8 %ny, i8 %nz
|
||||
%r = select i1 %cmpyx, i8 %minxz, i8 %minyz
|
||||
ret i8 %r
|
||||
}
|
||||
|
||||
define i32 @compute_min_3(i32 %x, i32 %y, i32 %z) {
|
||||
; CHECK-LABEL: @compute_min_3(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 %x, %y
|
||||
|
|
Loading…
Reference in New Issue