[llvm] r299821 - [InstCombine] Extend a canonicalization check to apply to vector constants too.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 8 23:12:39 PDT 2017


Author: ctopper
Date: Sun Apr  9 01:12:39 2017
New Revision: 299821

URL: http://llvm.org/viewvc/llvm-project?rev=299821&view=rev
Log:
[InstCombine] Extend a canonicalization check to apply to vector constants too.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    llvm/trunk/test/Transforms/InstCombine/and.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=299821&r1=299820&r2=299821&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Sun Apr  9 01:12:39 2017
@@ -2567,8 +2567,9 @@ Instruction *InstCombiner::visitXor(Bina
                Op0I->hasOneUse()){
       if (A == Op1)                                        // (A&B)^A -> (B&A)^A
         std::swap(A, B);
+      const APInt *C;
       if (B == Op1 &&                                      // (B&A)^A == ~B & A
-          !isa<ConstantInt>(Op1)) {  // Canonical form is (B&C)^C
+          !match(Op1, m_APInt(C))) {  // Canonical form is (B&C)^C
         return BinaryOperator::CreateAnd(Builder->CreateNot(A), Op1);
       }
     }

Modified: llvm/trunk/test/Transforms/InstCombine/and.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/and.ll?rev=299821&r1=299820&r2=299821&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/and.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/and.ll Sun Apr  9 01:12:39 2017
@@ -431,8 +431,8 @@ define i32 @test33b(i32 %b) {
 
 define <2 x i32> @test33vec(<2 x i32> %b) {
 ; CHECK-LABEL: @test33vec(
-; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i32> [[B:%.*]], <i32 1, i32 1>
-; CHECK-NEXT:    [[TMP_10:%.*]] = and <2 x i32> [[TMP1]], <i32 1, i32 1>
+; CHECK-NEXT:    [[TMP_4_MASK:%.*]] = and <2 x i32> [[B:%.*]], <i32 1, i32 1>
+; CHECK-NEXT:    [[TMP_10:%.*]] = xor <2 x i32> [[TMP_4_MASK]], <i32 1, i32 1>
 ; CHECK-NEXT:    [[TMP_12:%.*]] = and <2 x i32> [[B]], <i32 -2, i32 -2>
 ; CHECK-NEXT:    [[TMP_13:%.*]] = or <2 x i32> [[TMP_12]], [[TMP_10]]
 ; CHECK-NEXT:    ret <2 x i32> [[TMP_13]]
@@ -446,8 +446,8 @@ define <2 x i32> @test33vec(<2 x i32> %b
 
 define <2 x i32> @test33vecb(<2 x i32> %b) {
 ; CHECK-LABEL: @test33vecb(
-; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i32> [[B:%.*]], <i32 1, i32 1>
-; CHECK-NEXT:    [[TMP_10:%.*]] = and <2 x i32> [[TMP1]], <i32 1, i32 1>
+; CHECK-NEXT:    [[TMP_4_MASK:%.*]] = and <2 x i32> [[B:%.*]], <i32 1, i32 1>
+; CHECK-NEXT:    [[TMP_10:%.*]] = xor <2 x i32> [[TMP_4_MASK]], <i32 1, i32 1>
 ; CHECK-NEXT:    [[TMP_12:%.*]] = and <2 x i32> [[B]], <i32 -2, i32 -2>
 ; CHECK-NEXT:    [[TMP_13:%.*]] = or <2 x i32> [[TMP_10]], [[TMP_12]]
 ; CHECK-NEXT:    ret <2 x i32> [[TMP_13]]




More information about the llvm-commits mailing list