[llvm] [ValueTracking] Infer is-power-of-2 from assumptions. (PR #107745)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 8 02:25:14 PDT 2024
================
@@ -2222,6 +2238,20 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
if (OrZero && V->getType()->getScalarSizeInBits() == 1)
return true;
+ // Try to infer from assumptions.
+ if (Q.AC && Q.CxtI) {
+ for (auto &AssumeVH : Q.AC->assumptionsFor(V)) {
+ if (!AssumeVH)
+ continue;
+ CallInst *I = cast<CallInst>(AssumeVH);
+ if (!isValidAssumeForContext(I, Q.CxtI, Q.DT))
----------------
nikic wrote:
I'd check isImpliedToBeAPowerOfTwoFromCond first, it should be cheaper than isValidAssumeForContext.
https://github.com/llvm/llvm-project/pull/107745
More information about the llvm-commits
mailing list