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

Jay Foad via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Apr 7 12:42:10 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);
----------------
jayfoad wrote:

Surely ConstantData is just constant, so it is guaranteed to be loop-invariant, so this should be:
```suggestion
      return isa<ConstantData>(PtrOp) || L->isLoopInvariant(PtrOp);
```
And couldn't the ConstantData check be done inside of isLoopInvariant?

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


More information about the llvm-branch-commits mailing list