[llvm] [CodeGen] Do not remove IMPLICIT_DEF unless all uses have undef flag added (PR #188133)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 08:33:58 PDT 2026
================
@@ -102,38 +102,59 @@ void ProcessImplicitDefs::processImplicitDef(MachineInstr *MI) {
}
// This is a physreg implicit-def.
- // Look for the first instruction to use or define an alias.
- MachineBasicBlock::instr_iterator UserMI = MI->getIterator();
- MachineBasicBlock::instr_iterator UserE = MI->getParent()->instr_end();
- bool Found = false;
- for (++UserMI; UserMI != UserE; ++UserMI) {
- for (MachineOperand &MO : UserMI->operands()) {
+ // Trim any extra operands.
+ for (unsigned i = MI->getNumOperands() - 1; i; --i)
+ MI->removeOperand(i);
+
+ // Try to add undef flag to all uses. If all uses are updated remove
+ // implicit-def.
+ MachineBasicBlock::instr_iterator SearchMI = MI->getIterator();
+ MachineBasicBlock::instr_iterator SearchE = MI->getParent()->instr_end();
+ bool ImplicitDefIsDead = false;
+ bool SearchedWholeBlock = true;
+ constexpr unsigned SearchLimit = 35;
+ unsigned Count = 0;
+ for (++SearchMI; SearchMI != SearchE; ++SearchMI) {
+ if (++Count > SearchLimit) {
----------------
LU-JOHN wrote:
Fixed.
https://github.com/llvm/llvm-project/pull/188133
More information about the llvm-commits
mailing list