[PATCH] D114962: [Support] improve known bits analysis for multiply with 1-bit op (bool)

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 13:28:47 PST 2021


efriedma added inline comments.


================
Comment at: llvm/lib/Support/KnownBits.cpp:436
+      assert(LeadZ < RHSLeadZ && "Specialization should only improve estimate");
+      LeadZ = RHSLeadZ;
+    } else if (RHSLeadZ == BitWidth - 1) {
----------------
You could generalize further in two ways:

1. if one operand is known to be 0 or 1, we can copy all the known zero bits from the other operand to the result, not just the leading zeros.
2. If either operand has at most one bit set, we can use `LeadZ = std::max(LHSLeadZ + RHSLeadZ + 1, BitWidth) - BitWidth;`.

Not sure either one is actually useful, though.


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

https://reviews.llvm.org/D114962



More information about the llvm-commits mailing list