HomePhabricator

[MachineCopyPropagation] Extend MCP to do trivial copy backward propagation

Authored by lkail on Dec 3 2019, 7:19 PM.

Description

[MachineCopyPropagation] Extend MCP to do trivial copy backward propagation

Summary:
This patch mainly do such transformation

$R0 = OP ...
... // No read/clobber of $R0 and $R1
$R1 = COPY $R0 // $R0 is killed

Replace $R0 with $R1 and remove the COPY, we have

$R1 = OP ...

This transformation can also expose more opportunities for existing
copy elimination in MCP.

Differential Revision: https://reviews.llvm.org/D67794

Event Timeline

lkail added a comment.EditedDec 4 2019, 10:12 PM
clang-10: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/llvm/lib/CodeGen/MachineOperand.cpp:118: bool llvm::MachineOperand::isRenamable() const: Assertion `Register::isPhysicalRegister(getReg()) && "isRenamable should only be checked on physical registers"' failed.

It misses check if the register is zero before invoking isRenamable.