[PATCH] D108992: [KnownBits] Add support for X*X self-multiplication

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 6 11:40:33 PST 2022


This revision was not accepted when it landed; it landed in state "Changes Planned".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94453952fc95: [KnownBits] Add support for X*X self-multiplication (update) (authored by RKSimon).

Changed prior to commit:
  https://reviews.llvm.org/D108992?vs=371032&id=406269#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108992/new/

https://reviews.llvm.org/D108992

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


Index: llvm/lib/Support/KnownBits.cpp
===================================================================
--- llvm/lib/Support/KnownBits.cpp
+++ llvm/lib/Support/KnownBits.cpp
@@ -413,12 +413,13 @@
 }
 
 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 @@
   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);
Index: llvm/include/llvm/Support/KnownBits.h
===================================================================
--- llvm/include/llvm/Support/KnownBits.h
+++ llvm/include/llvm/Support/KnownBits.h
@@ -324,7 +324,7 @@
 
   /// 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108992.406269.patch
Type: text/x-patch
Size: 1918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220206/1af47fe4/attachment.bin>


More information about the llvm-commits mailing list