[llvm] r299836 - [InstCombine] Add test cases demonstrating missing handling for the commuted version of a transform. NFC.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 9 23:53:25 PDT 2017
Author: ctopper
Date: Mon Apr 10 01:53:25 2017
New Revision: 299836
URL: http://llvm.org/viewvc/llvm-project?rev=299836&view=rev
Log:
[InstCombine] Add test cases demonstrating missing handling for the commuted version of a transform. NFC.
Modified:
llvm/trunk/test/Transforms/InstCombine/xor2.ll
Modified: llvm/trunk/test/Transforms/InstCombine/xor2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor2.ll?rev=299836&r1=299835&r2=299836&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor2.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/xor2.ll Mon Apr 10 01:53:25 2017
@@ -144,6 +144,20 @@ define i32 @test9(i32 %b, i32 %c) {
ret i32 %xor2
}
+; (A & B) ^ (B ^ A) -> (A | B)
+define i32 @test9b(i32 %b, i32 %c) {
+; CHECK-LABEL: @test9b(
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[B:%.*]], [[C:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[C]], [[B]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[AND]], [[XOR]]
+; CHECK-NEXT: ret i32 [[XOR2]]
+;
+ %and = and i32 %b, %c
+ %xor = xor i32 %c, %b
+ %xor2 = xor i32 %and, %xor
+ ret i32 %xor2
+}
+
; (A ^ B) ^ (A & B) -> (A | B)
define i32 @test10(i32 %b, i32 %c) {
; CHECK-LABEL: @test10(
@@ -155,6 +169,20 @@ define i32 @test10(i32 %b, i32 %c) {
%xor2 = xor i32 %xor, %and
ret i32 %xor2
}
+
+; (A ^ B) ^ (A & B) -> (A | B)
+define i32 @test10b(i32 %b, i32 %c) {
+; CHECK-LABEL: @test10b(
+; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[B:%.*]], [[C:%.*]]
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[C]], [[B]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[XOR]], [[AND]]
+; CHECK-NEXT: ret i32 [[XOR2]]
+;
+ %xor = xor i32 %b, %c
+ %and = and i32 %c, %b
+ %xor2 = xor i32 %xor, %and
+ ret i32 %xor2
+}
define i32 @test11(i32 %A, i32 %B) {
; CHECK-LABEL: @test11(
More information about the llvm-commits
mailing list