[llvm-branch-commits] [llvm] LICM: Avoid looking at use list of constant data (PR #134690)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Apr 7 12:44:59 PDT 2025


================
@@ -2294,10 +2294,14 @@ collectPromotionCandidates(MemorySSA *MSSA, AliasAnalysis *AA, Loop *L) {
   AliasSetTracker AST(BatchAA);
 
   auto IsPotentiallyPromotable = [L](const Instruction *I) {
-    if (const auto *SI = dyn_cast<StoreInst>(I))
-      return L->isLoopInvariant(SI->getPointerOperand());
-    if (const auto *LI = dyn_cast<LoadInst>(I))
-      return L->isLoopInvariant(LI->getPointerOperand());
+    if (const auto *SI = dyn_cast<StoreInst>(I)) {
+      const Value *PtrOp = SI->getPointerOperand();
+      return !isa<ConstantData>(PtrOp) && L->isLoopInvariant(PtrOp);
----------------
nikic wrote:

It's loop invariant -- the point here is to skip promotion for constant data, even if its loop invariant, because promotion works by iterating over the use list. In practice, this basically means that we'll not try to promote loads/stores to null pointers, which is just a bugpoint/reduce-ism.

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


More information about the llvm-branch-commits mailing list