[llvm] b257657 - Revert rGbbeb08497ce58 "Revert "[GlobalISel] GISelKnownBits::computeKnownBitsImpl - Replace TargetOpcode::G_MUL handling with the common KnownBits::computeForMul implementation""

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 02:40:29 PST 2020


Author: Simon Pilgrim
Date: 2020-11-05T10:39:53Z
New Revision: b25765792be35393a9057774a0be2b53b1ff5bf2

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

LOG: Revert rGbbeb08497ce58 "Revert "[GlobalISel] GISelKnownBits::computeKnownBitsImpl - Replace TargetOpcode::G_MUL handling with the common KnownBits::computeForMul implementation""

Updated the GISel KnownBits tests as KnownBits::computeForMul allows more accurate computation.

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
    llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
index 81a89a6eb0b7..862764f30522 100644
--- a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
@@ -287,20 +287,7 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
                          Depth + 1);
     computeKnownBitsImpl(MI.getOperand(1).getReg(), Known2, DemandedElts,
                          Depth + 1);
-    // If low bits are zero in either operand, output low known-0 bits.
-    // Also compute a conservative estimate for high known-0 bits.
-    // More trickiness is possible, but this is sufficient for the
-    // interesting case of alignment computation.
-    unsigned TrailZ =
-        Known.countMinTrailingZeros() + Known2.countMinTrailingZeros();
-    unsigned LeadZ =
-        std::max(Known.countMinLeadingZeros() + Known2.countMinLeadingZeros(),
-                 BitWidth) -
-        BitWidth;
-
-    Known.resetAll();
-    Known.Zero.setLowBits(std::min(TrailZ, BitWidth));
-    Known.Zero.setHighBits(std::min(LeadZ, BitWidth));
+    Known = KnownBits::computeForMul(Known, Known2);
     break;
   }
   case TargetOpcode::G_SELECT: {

diff  --git a/llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp b/llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
index 5f1d24b1078b..7888f461957e 100644
--- a/llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
@@ -300,8 +300,8 @@ TEST_F(AArch64GISelMITest, TestKnownBits) {
   GISelKnownBits Info(*MF);
   KnownBits Known = Info.getKnownBits(SrcReg);
   EXPECT_FALSE(Known.hasConflict());
-  EXPECT_EQ(0u, Known.One.getZExtValue());
-  EXPECT_EQ(31u, Known.Zero.getZExtValue());
+  EXPECT_EQ(32u, Known.One.getZExtValue());
+  EXPECT_EQ(95u, Known.Zero.getZExtValue());
   APInt Zeroes = Info.getKnownZeroes(SrcReg);
   EXPECT_EQ(Known.Zero, Zeroes);
 }


        


More information about the llvm-commits mailing list