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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 14:48:11 PST 2021


spatel 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) {
----------------
spatel wrote:
> efriedma wrote:
> > 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.
> Thanks, Eli!
> If we all bits are known, then we should simplify before we get here? 
> I like the 2nd idea - that might get me closer to the solution for the motivating problem, and if I'm seeing it correctly, it can be implemented with just one extra line of code. Let me come up with some more tests to exercise that...
Disregard the question - I misread the suggestion.


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

https://reviews.llvm.org/D114962



More information about the llvm-commits mailing list