forked from OSchip/llvm-project
[InstSimplify] Add test cases for missing fold (A & B) | ~(A ^ B) -> ~(A ^ B).
llvm-svn: 303367
This commit is contained in:
parent
6796c0b97f
commit
93898495b9
|
@ -735,6 +735,74 @@ define i32 @test54(i32 %a, i32 %b) {
|
|||
ret i32 %or
|
||||
}
|
||||
|
||||
; (A & B) | ~(A ^ B) -> ~(A ^ B)
|
||||
|
||||
define i32 @test55(i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @test55(
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[XNOR:%.*]] = xor i32 [[XOR]], -1
|
||||
; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[XNOR]]
|
||||
; CHECK-NEXT: ret i32 [[OR]]
|
||||
;
|
||||
%and = and i32 %a, %b
|
||||
%xor = xor i32 %a, %b
|
||||
%xnor = xor i32 %xor, -1
|
||||
%or = or i32 %and, %xnor
|
||||
ret i32 %or
|
||||
}
|
||||
|
||||
; ~(A ^ B) | (A & B) -> ~(A ^ B)
|
||||
|
||||
define i32 @test56(i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @test56(
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[XNOR:%.*]] = xor i32 [[XOR]], -1
|
||||
; CHECK-NEXT: [[OR:%.*]] = or i32 [[XNOR]], [[AND]]
|
||||
; CHECK-NEXT: ret i32 [[OR]]
|
||||
;
|
||||
%and = and i32 %a, %b
|
||||
%xor = xor i32 %a, %b
|
||||
%xnor = xor i32 %xor, -1
|
||||
%or = or i32 %xnor, %and
|
||||
ret i32 %or
|
||||
}
|
||||
|
||||
; (B & A) | ~(A ^ B) -> ~(A ^ B)
|
||||
|
||||
define i32 @test57(i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @test57(
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[B:%.*]], [[A:%.*]]
|
||||
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[XNOR:%.*]] = xor i32 [[XOR]], -1
|
||||
; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[XNOR]]
|
||||
; CHECK-NEXT: ret i32 [[OR]]
|
||||
;
|
||||
%and = and i32 %b, %a
|
||||
%xor = xor i32 %a, %b
|
||||
%xnor = xor i32 %xor, -1
|
||||
%or = or i32 %and, %xnor
|
||||
ret i32 %or
|
||||
}
|
||||
|
||||
; ~(A ^ B) | (A & B) -> ~(A ^ B)
|
||||
|
||||
define i32 @test58(i32 %a, i32 %b) {
|
||||
; CHECK-LABEL: @test58(
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[B:%.*]], [[A:%.*]]
|
||||
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[A]], [[B]]
|
||||
; CHECK-NEXT: [[XNOR:%.*]] = xor i32 [[XOR]], -1
|
||||
; CHECK-NEXT: [[OR:%.*]] = or i32 [[XNOR]], [[AND]]
|
||||
; CHECK-NEXT: ret i32 [[OR]]
|
||||
;
|
||||
%and = and i32 %b, %a
|
||||
%xor = xor i32 %a, %b
|
||||
%xnor = xor i32 %xor, -1
|
||||
%or = or i32 %xnor, %and
|
||||
ret i32 %or
|
||||
}
|
||||
|
||||
define i8 @lshr_perfect_mask(i8 %x) {
|
||||
; CHECK-LABEL: @lshr_perfect_mask(
|
||||
; CHECK-NEXT: [[SH:%.*]] = lshr i8 %x, 5
|
||||
|
|
Loading…
Reference in New Issue