diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-09 06:12:39 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-09 06:12:39 +0000 |
commit | e63c21b1bab0e99b830f6e56db127f06133567fd (patch) | |
tree | 409b44d40ad51206992764a49d6877b0d138c3d2 | |
parent | 1c5af0d4007895b64c7760bed63d9bebf6b8399b (diff) | |
download | bcm5719-llvm-e63c21b1bab0e99b830f6e56db127f06133567fd.tar.gz bcm5719-llvm-e63c21b1bab0e99b830f6e56db127f06133567fd.zip |
[InstCombine] Extend a canonicalization check to apply to vector constants too.
llvm-svn: 299821
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/and.ll | 8 |
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 62fad853908..e94b6797d11 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2567,8 +2567,9 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { 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); } } diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll index be8aba99916..868042be773 100644 --- a/llvm/test/Transforms/InstCombine/and.ll +++ b/llvm/test/Transforms/InstCombine/and.ll @@ -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]] |