[llvm] [ValueTracking] Infer is-power-of-2 from assumptions. (PR #107745)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 8 09:00:22 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))
----------------
dtcxzyw wrote:

Done.

https://github.com/llvm/llvm-project/pull/107745


More information about the llvm-commits mailing list