[llvm] [KnownBits][SelectionDAG] Add KnownBits::clmul. Support trailing bits. NFC (PR #177517)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 23 09:22:27 PST 2026
================
@@ -602,6 +602,41 @@ KnownBits KnownBits::ashr(const KnownBits &LHS, const KnownBits &RHS,
return Known;
}
+KnownBits KnownBits::clmul(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+
+ // An m*n result will always fit in m+n-1 bits since there are no carries.
+ unsigned ActiveBits = std::min(
+ BitWidth, LHS.countMaxActiveBits() + RHS.countMaxActiveBits() - 1);
----------------
topperc wrote:
The -1u will be clipped by the std::min and the trailing bits code will determine that all bits are known so we get still get the optimal answer. But we should avoid underflow in the math. I'll fix.
https://github.com/llvm/llvm-project/pull/177517
More information about the llvm-commits
mailing list