Skip to content

Commit 08f682e

Browse files
vladimirradosavljevicakiramenai
authored andcommitted
[MCP] Skip invalidating constant regs during forward propagation
Before this patch, redundant COPY couldn't be removed for the following case: %reg1 = COPY %const-reg ... // No use of %reg1 but there is a def/use of %const-reg %reg2 = COPY killed %reg1 where this can be optimized to: ... // No use of %reg1 but there is a def/use of %const-reg %reg2 = COPY %const-reg This patch allows for such optimization by not invalidating constant registers. This is safe even where constant registers are defined, as architectures like AArch64 and RISCV replace a dead definition of a GPR with a zero constant register for certain instructions. Upstream PR: llvm/llvm-project#111129 Signed-off-by: Vladimir Radosavljevic <[email protected]>
1 parent 1859f9a commit 08f682e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,12 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
885885
assert(!Reg.isVirtual() &&
886886
"MachineCopyPropagation should be run after register allocation!");
887887

888+
// EVM local begin
889+
// Skip invalidating constant registers.
890+
if (MRI->isReserved(Reg) && MRI->isConstantPhysReg(Reg))
891+
continue;
892+
// EVM local end
893+
888894
if (MO.isDef() && !MO.isEarlyClobber()) {
889895
Defs.push_back(Reg.asMCReg());
890896
continue;

0 commit comments

Comments
 (0)