[llvm] [SCCP] Consider provenance when propagating constant ptrs (PR #160083)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 08:21:13 PDT 2025


================
@@ -82,6 +83,26 @@ bool SCCPSolver::tryToReplaceWithConstant(Value *V) {
     return false;
   }
 
+  // Perform constant pointer propagation as long as assuming PredicateInfo
+  // derived equality between the two holds, and their provenance is the same.
+  if (auto *I = dyn_cast<Instruction>(V); I && I->getType()->isPointerTy()) {
+    if (getPredicateInfoFor(I)) {
----------------
antoniofrighetto wrote:

Hm, right. Any suggestions on whether calling getPredicateInfoFor() over instruction operands may be a possibility here? Alternatively, after materializing the new copy and walking the uses to be renamed in PredicateInfo, could keep (and expose) a small map copy -> user's new use be an option?

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


More information about the llvm-commits mailing list