[llvm] [Support] Adding fast-path for KnownBits's udiv when RHS is constant (PR #189779)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 03:05:47 PDT 2026
================
@@ -1209,6 +1209,26 @@ KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS,
return Known;
}
+ if (RHS.isConstant()) {
----------------
jayfoad wrote:
> I thought about reusing `LHS.lshr`, but it’s quite cumbersome for this specific case and includes conflict handling, it has loops (even though our case would only require a single iteration) and a lot of branching. Here, one of the goals is not only to improve accuracy but also to speed up the computation itself for this particular case.
Hmm. Maybe you could put your fast path code in a new overload `KnownBits::lshr(unsigned)`. Then we could call it from `lshr(KnownBits)` too.
> What about Divisor.isOne()? Do you think that’s too rare case?
Yes.
https://github.com/llvm/llvm-project/pull/189779
More information about the llvm-commits
mailing list