[llvm] [SLP]Remove operands upon marking instruction for deletion. (PR #97409)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 09:59:14 PDT 2024
================
@@ -14064,11 +14070,24 @@ Value *BoUpSLP::vectorizeTree(
}
#endif
LLVM_DEBUG(dbgs() << "SLP: \tErasing scalar:" << *Scalar << ".\n");
- eraseInstruction(cast<Instruction>(Scalar));
+ auto *I = cast<Instruction>(Scalar);
+ // Clear the operands, marking for deletion trivially dead operands.
+ for (unsigned Idx : seq<unsigned>(I->getNumOperands())) {
+ // Ignore pointer operand of stores to keep correct DIAssignID.
+ if (isa<StoreInst>(I) && Idx == 1)
+ continue;
+ Value *Op = I->getOperand(Idx);
+ I->setOperand(Idx, PoisonValue::get(Op->getType()));
+ if (auto *OpI = dyn_cast<Instruction>(Op))
+ if (!isDeleted(OpI) && isInstructionTriviallyDead(OpI, TLI) &&
+ Entry->VectorizedValue != OpI)
+ eraseInstruction(OpI);
----------------
RKSimon wrote:
Similar code to the version in HorizontalReduction - pull out into a small helper?
https://github.com/llvm/llvm-project/pull/97409
More information about the llvm-commits
mailing list