summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/or.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/InstCombine/or.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/or.ll17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll
index facd63019fe..2c9088428bd 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -596,7 +596,7 @@ define i32 @test42_commuted_xor(i32 %a, i32 %b) {
ret i32 %or
}
-; Commute operands of the 'or'.
+; (A & ~B) | (A ^ B) -> A ^ B
define i32 @test43(i32 %a, i32 %b) {
; CHECK-LABEL: @test43(
@@ -622,6 +622,9 @@ define i32 @test43_commuted_and(i32 %a, i32 %b) {
ret i32 %or
}
+; Commute operands of the 'or'.
+; (A ^ B) | (A & ~B) -> A ^ B
+
define i32 @test44(i32 %a, i32 %b) {
; CHECK-LABEL: @test44(
; CHECK-NEXT: [[OR:%.*]] = xor i32 %a, %b
@@ -634,6 +637,18 @@ define i32 @test44(i32 %a, i32 %b) {
ret i32 %or
}
+define i32 @test44_commuted_and(i32 %a, i32 %b) {
+; CHECK-LABEL: @test44_commuted_and(
+; CHECK-NEXT: [[OR:%.*]] = xor i32 %a, %b
+; CHECK-NEXT: ret i32 [[OR]]
+;
+ %xor = xor i32 %a, %b
+ %neg = xor i32 %b, -1
+ %and = and i32 %neg, %a
+ %or = or i32 %xor, %and
+ ret i32 %or
+}
+
define i32 @test45(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: @test45(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %x, %z
OpenPOWER on IntegriCloud