[llvm] [GVN] Skip instructions without value numbers in performScalarPRE (PR #219851)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 00:32:41 PDT 2026


================
@@ -2116,7 +2116,11 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load,
     if (GetElementPtrInst *GEP =
             dyn_cast<GetElementPtrInst>(Load->getOperand(0))) {
       for (Use &U : GEP->indices())
-        if (Instruction *I = dyn_cast<Instruction>(U.get()))
+        // Skip instructions GVN inserted in this iteration, e.g. when coercing
+        // an available load value: they have no value number yet, and no
+        // leaders either, so PRE cannot do anything with them until the next
+        // iteration numbers them.
----------------
antoniofrighetto wrote:

```suggestion
       // Instructions inserted by GVN during this iteration (e.g. coercion casts
        // from MaterializeAdjustedValue) may not have value numbers yet are skipped.
```

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


More information about the llvm-commits mailing list