[llvm] r301125 - [InstCombine] add tests for add-to-xor commuted variants; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 23 06:37:05 PDT 2017
Author: spatel
Date: Sun Apr 23 08:37:05 2017
New Revision: 301125
URL: http://llvm.org/viewvc/llvm-project?rev=301125&view=rev
Log:
[InstCombine] add tests for add-to-xor commuted variants; NFC
1 out of the 4 tests commuted the operands, so there's an asymmetry
somewhere under this in how we handle these transforms.
Modified:
llvm/trunk/test/Transforms/InstCombine/and-or-not.ll
Modified: llvm/trunk/test/Transforms/InstCombine/and-or-not.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/and-or-not.ll?rev=301125&r1=301124&r2=301125&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/and-or-not.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/and-or-not.ll Sun Apr 23 08:37:05 2017
@@ -4,20 +4,62 @@
; (a | b) & ~(a & b) --> a ^ b
-define i32 @and_to_xor(i32 %a, i32 %b) {
-; CHECK-LABEL: @and_to_xor(
+define i32 @and_to_xor1(i32 %a, i32 %b) {
+; CHECK-LABEL: @and_to_xor1(
+; CHECK-NEXT: [[AND2:%.*]] = xor i32 %a, %b
+; CHECK-NEXT: ret i32 [[AND2]]
+;
+ %or = or i32 %a, %b
+ %and = and i32 %a, %b
+ %not = xor i32 %and, -1
+ %and2 = and i32 %or, %not
+ ret i32 %and2
+}
+
+; ~(a & b) & (a | b) --> a ^ b
+
+define i32 @and_to_xor2(i32 %a, i32 %b) {
+; CHECK-LABEL: @and_to_xor2(
+; CHECK-NEXT: [[AND2:%.*]] = xor i32 %a, %b
+; CHECK-NEXT: ret i32 [[AND2]]
+;
+ %or = or i32 %a, %b
+ %and = and i32 %a, %b
+ %not = xor i32 %and, -1
+ %and2 = and i32 %not, %or
+ ret i32 %and2
+}
+
+; (a | b) & ~(b & a) --> a ^ b
+
+define i32 @and_to_xor3(i32 %a, i32 %b) {
+; CHECK-LABEL: @and_to_xor3(
; CHECK-NEXT: [[AND2:%.*]] = xor i32 %b, %a
; CHECK-NEXT: ret i32 [[AND2]]
;
- %or = or i32 %b, %a
+ %or = or i32 %a, %b
%and = and i32 %b, %a
%not = xor i32 %and, -1
%and2 = and i32 %or, %not
ret i32 %and2
}
-define <4 x i32> @and_to_xor_vec(<4 x i32> %a, <4 x i32> %b) {
-; CHECK-LABEL: @and_to_xor_vec(
+; ~(a & b) & (b | a) --> a ^ b
+
+define i32 @and_to_xor4(i32 %a, i32 %b) {
+; CHECK-LABEL: @and_to_xor4(
+; CHECK-NEXT: [[AND2:%.*]] = xor i32 %a, %b
+; CHECK-NEXT: ret i32 [[AND2]]
+;
+ %or = or i32 %b, %a
+ %and = and i32 %a, %b
+ %not = xor i32 %and, -1
+ %and2 = and i32 %not, %or
+ ret i32 %and2
+}
+
+define <4 x i32> @and_to_xor1_vec(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: @and_to_xor1_vec(
; CHECK-NEXT: [[AND2:%.*]] = xor <4 x i32> %a, %b
; CHECK-NEXT: ret <4 x i32> [[AND2]]
;
More information about the llvm-commits
mailing list