[KnownBits] Add support for X*X self-multiplication (update)
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 6 Feb 2022 19:40:08 +0000 (19:40 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 6 Feb 2022 19:40:08 +0000 (19:40 +0000)
Rename the SelfMultiply argument to make it clearer that the argument must not be undef

Differential Revision: https://reviews.llvm.org/D108992

llvm/include/llvm/Support/KnownBits.h
llvm/lib/Support/KnownBits.cpp

index 96b7753e9b208ca89493e4df20bbd10713654858..1af7130afd9afb1d9ea917ba6adc98a53b59f34e 100644 (file)
@@ -324,7 +324,7 @@ public:
 
   /// Compute known bits resulting from multiplying LHS and RHS.
   static KnownBits mul(const KnownBits &LHS, const KnownBits &RHS,
-                       bool SelfMultiply = false);
+                       bool NoUndefSelfMultiply = false);
 
   /// Compute known bits from sign-extended multiply-hi.
   static KnownBits mulhs(const KnownBits &LHS, const KnownBits &RHS);
index 8e154067abc0ad9e07fdae29cce3e5f7d01c69dd..5ec85061e8501903975fca1c4a3c04b36df86bcb 100644 (file)
@@ -413,12 +413,13 @@ KnownBits KnownBits::abs(bool IntMinIsPoison) const {
 }
 
 KnownBits KnownBits::mul(const KnownBits &LHS, const KnownBits &RHS,
-                         bool SelfMultiply) {
+                         bool NoUndefSelfMultiply) {
   unsigned BitWidth = LHS.getBitWidth();
   assert(BitWidth == RHS.getBitWidth() && !LHS.hasConflict() &&
          !RHS.hasConflict() && "Operand mismatch");
-  assert((!SelfMultiply || (LHS.One == RHS.One && LHS.Zero == RHS.Zero)) &&
-         "Self multiplication knownbits mismatch");
+  assert(
+      (!NoUndefSelfMultiply || (LHS.One == RHS.One && LHS.Zero == RHS.Zero)) &&
+      "Self multiplication knownbits mismatch");
 
   // Compute the high known-0 bits by multiplying the unsigned max of each side.
   // Conservatively, M active bits * N active bits results in M + N bits in the
@@ -501,7 +502,7 @@ KnownBits KnownBits::mul(const KnownBits &LHS, const KnownBits &RHS,
   Res.One = BottomKnown.getLoBits(ResultBitsKnown);
 
   // If we're self-multiplying then bit[1] is guaranteed to be zero.
-  if (SelfMultiply && BitWidth > 1) {
+  if (NoUndefSelfMultiply && BitWidth > 1) {
     assert(Res.One[1] == 0 &&
            "Self-multiplication failed Quadratic Reciprocity!");
     Res.Zero.setBit(1);