[llvm] [SIFoldOperands] Folding immediate into a copy invalidates candidates in the fold list (PR #148187)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 11 03:52:06 PDT 2025
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>,
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>,
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/148187 at github.com>
================
@@ -1785,9 +1787,13 @@ bool SIFoldOperandsImpl::foldInstOperand(MachineInstr &MI,
if (Fold.isImm() && tryConstantFoldOp(Fold.UseMI)) {
LLVM_DEBUG(dbgs() << "Constant folded " << *Fold.UseMI);
+ // The instruction was folded into a copy, we have to skip any other
+ // occurence of UseMI in the fold list
+ End = std::remove_if(FoldIt + 1, End, [&](const FoldCandidate &F) {
----------------
arsenm wrote:
We really need to rewrite this pass. The fold list is garbage. It would be a lot simpler to just track a map of foldable sources like peephole opt does
https://github.com/llvm/llvm-project/pull/148187
More information about the llvm-commits
mailing list