[llvm] 9d40292 - [ValueTracking] Add computeKnownBits DemandedElts support to XOR instructions (PR36319)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 18 13:25:42 PDT 2020


Author: Simon Pilgrim
Date: 2020-03-18T20:24:14Z
New Revision: 9d40292a64223c42bae7ffcc414702bc4394dafd

URL: https://github.com/llvm/llvm-project/commit/9d40292a64223c42bae7ffcc414702bc4394dafd
DIFF: https://github.com/llvm/llvm-project/commit/9d40292a64223c42bae7ffcc414702bc4394dafd.diff

LOG: [ValueTracking] Add computeKnownBits DemandedElts support to XOR instructions (PR36319)

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp
    llvm/test/Transforms/InstSimplify/or.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index d47d38dca8a6..f1adc037d17f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1137,8 +1137,8 @@ static void computeKnownBitsFromOperator(const Operator *I,
     Known.One |= Known2.One;
     break;
   case Instruction::Xor: {
-    computeKnownBits(I->getOperand(1), Known, Depth + 1, Q);
-    computeKnownBits(I->getOperand(0), Known2, Depth + 1, Q);
+    computeKnownBits(I->getOperand(1), DemandedElts, Known, Depth + 1, Q);
+    computeKnownBits(I->getOperand(0), DemandedElts, Known2, Depth + 1, Q);
 
     // Output known-0 bits are known if clear or set in both the LHS & RHS.
     APInt KnownZeroOut = (Known.Zero & Known2.Zero) | (Known.One & Known2.One);

diff  --git a/llvm/test/Transforms/InstSimplify/or.ll b/llvm/test/Transforms/InstSimplify/or.ll
index af301f118d77..7369cddf2fbe 100644
--- a/llvm/test/Transforms/InstSimplify/or.ll
+++ b/llvm/test/Transforms/InstSimplify/or.ll
@@ -112,12 +112,7 @@ define i8 @test11(i8 %A) {
 
 define i8 @test11v(<2 x i8> %A) {
 ; CHECK-LABEL: @test11v(
-; CHECK-NEXT:    [[B:%.*]] = or <2 x i8> [[A:%.*]], <i8 -2, i8 0>
-; CHECK-NEXT:    [[CV:%.*]] = xor <2 x i8> [[B]], <i8 13, i8 13>
-; CHECK-NEXT:    [[C:%.*]] = extractelement <2 x i8> [[CV]], i32 0
-; CHECK-NEXT:    [[D:%.*]] = or i8 [[C]], 1
-; CHECK-NEXT:    [[E:%.*]] = xor i8 [[D]], 12
-; CHECK-NEXT:    ret i8 [[E]]
+; CHECK-NEXT:    ret i8 -1
 ;
   %B = or <2 x i8> %A, <i8 -2, i8 0>
   %CV = xor <2 x i8> %B, <i8 13, i8 13>


        


More information about the llvm-commits mailing list