[llvm] [ReplaceConstant] Don't create instructions for the same constant multiple times in the same basic block (PR #169141)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 27 04:11:03 PST 2025


================
@@ -105,7 +109,14 @@ bool llvm::convertUsersOfConstantsToInstructions(ArrayRef<Constant *> Consts,
       if (auto *C = dyn_cast<Constant>(U.get())) {
         if (ExpandableUsers.contains(C)) {
           Changed = true;
-          auto NewInsts = expandUser(BI, C);
+          SmallVector<Instruction *, 4> &NewInsts =
+              ConstantToInstructionMap[std::make_pair(C, BI->getParent())];
----------------
jayfoad wrote:

```suggestion
              ConstantToInstructionMap[std::pair(C, BI->getParent())];
```

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


More information about the llvm-commits mailing list