[llvm] [InstCombine] Support multi-use values in cast elimination transforms (PR #165877)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 31 10:41:50 PDT 2025


================
@@ -123,7 +143,22 @@ Value *InstCombinerImpl::EvaluateInDifferentType(Value *V, Type *Ty,
   }
 
   Res->takeName(I);
-  return InsertNewInstWith(Res, I->getIterator());
+  Value *Result = IC.InsertNewInstWith(Res, I->getIterator());
+  // There is no need in keeping track of the old value/new value relationship
+  // when we have only one user, we came have here from that user and no-one
+  // else cares.
+  if (!V->hasOneUse()) {
+    Processed[V] = Result;
+  }
----------------
dtcxzyw wrote:

```suggestion
  if (!V->hasOneUse())
    Processed[V] = Result;
```

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


More information about the llvm-commits mailing list