[llvm] [ValueTracking] AllowEphemerals for alignment assumptions. (PR #108632)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 02:37:14 PDT 2024


================
@@ -820,9 +820,12 @@ void llvm::computeKnownBitsFromContext(const Value *V, KnownBits &Known,
         continue;
       if (RetainedKnowledge RK = getKnowledgeFromBundle(
               *I, I->bundle_op_info_begin()[Elem.Index])) {
+        // Allow AllowEphemerals in isValidAssumeForContext, as the CxtI might
+        // be the producer of the pointer in the bundle. At the moment, align
+        // assumptions aren't optimized away.
         if (RK.WasOn == V && RK.AttrKind == Attribute::Alignment &&
             isPowerOf2_64(RK.ArgValue) &&
-            isValidAssumeForContext(I, Q.CxtI, Q.DT))
+            isValidAssumeForContext(I, Q.CxtI, Q.DT, /*AllowEphemerals*/ true))
----------------
fhahn wrote:

Yes, I suppose in the future instcombine (or elsewhere) could use computeKnownBitsForContext to remove redundant alignment assumptions, thus possibly using information from the assumption to remove the assumption itself. But not an issue for now

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


More information about the llvm-commits mailing list