diff options
Diffstat (limited to 'llvm/test/Transforms/InstCombine/or.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/or.ll | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll index 4fb1978615d..38b8ebc5adf 100644 --- a/llvm/test/Transforms/InstCombine/or.ll +++ b/llvm/test/Transforms/InstCombine/or.ll @@ -555,6 +555,8 @@ define i32 @test41(i32 %a, i32 %b) { ret i32 %or } +; (~A ^ B) | (A & B) -> (~A ^ B) + define i32 @test42(i32 %a, i32 %b) { ; CHECK-LABEL: @test42( ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 %a, -1 @@ -568,6 +570,42 @@ define i32 @test42(i32 %a, i32 %b) { ret i32 %or } +; FIXME: We miss the fold because the pattern matching is inadequate. + +define i32 @test42_commuted_and(i32 %a, i32 %b) { +; CHECK-LABEL: @test42_commuted_and( +; CHECK-NEXT: [[NEGA:%.*]] = xor i32 %a, -1 +; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[NEGA]], %b +; CHECK-NEXT: [[AND:%.*]] = and i32 %b, %a +; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR]], [[AND]] +; CHECK-NEXT: ret i32 [[OR]] +; + %nega = xor i32 %a, -1 + %xor = xor i32 %nega, %b + %and = and i32 %b, %a + %or = or i32 %xor, %and + ret i32 %or +} + +; FIXME: We miss the fold because the pattern matching is inadequate. + +define i32 @test42_commuted_xor(i32 %a, i32 %b) { +; CHECK-LABEL: @test42_commuted_xor( +; CHECK-NEXT: [[NEGA:%.*]] = xor i32 %a, -1 +; CHECK-NEXT: [[XOR:%.*]] = xor i32 %b, [[NEGA]] +; CHECK-NEXT: [[AND:%.*]] = and i32 %a, %b +; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR]], [[AND]] +; CHECK-NEXT: ret i32 [[OR]] +; + %nega = xor i32 %a, -1 + %xor = xor i32 %b, %nega + %and = and i32 %a, %b + %or = or i32 %xor, %and + ret i32 %or +} + +; Commute operands of the 'or'. + define i32 @test43(i32 %a, i32 %b) { ; CHECK-LABEL: @test43( ; CHECK-NEXT: [[OR:%.*]] = xor i32 %a, %b @@ -580,6 +618,23 @@ define i32 @test43(i32 %a, i32 %b) { ret i32 %or } +; FIXME: We miss the fold because the pattern matching is inadequate. + +define i32 @test43_commuted_and(i32 %a, i32 %b) { +; CHECK-LABEL: @test43_commuted_and( +; CHECK-NEXT: [[NEG:%.*]] = xor i32 %b, -1 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[NEG]], %a +; CHECK-NEXT: [[XOR:%.*]] = xor i32 %a, %b +; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[XOR]] +; CHECK-NEXT: ret i32 [[OR]] +; + %neg = xor i32 %b, -1 + %and = and i32 %neg, %a + %xor = xor i32 %a, %b + %or = or i32 %and, %xor + ret i32 %or +} + define i32 @test44(i32 %a, i32 %b) { ; CHECK-LABEL: @test44( ; CHECK-NEXT: [[OR:%.*]] = xor i32 %a, %b |