Skip to content

Commit 78b9c96

Browse files
vladimirradosavljevicakiramenai
authored andcommitted
[EraVM] Preserve register flags after expansion of PTR_TO_INT and MOVEIMM
Some optimizations like MachineCopyPropagation makes decisions based on the register flags, so in order for these optimizations to work correctly, we need to preserve flags after expansion of pseudo instructions. Signed-off-by: Vladimir Radosavljevic <[email protected]>
1 parent 2251b8c commit 78b9c96

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Target/EraVM/EraVMExpandPseudoInsts.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ bool EraVMExpandPseudo::runOnMachineFunction(MachineFunction &MF) {
116116
LLVM_DEBUG(dbgs() << "Found PTR_TO_INT: "; MI.dump());
117117
[[maybe_unused]] auto NewMI =
118118
BuildMI(*MI.getParent(), &MI, MI.getDebugLoc(),
119-
TII->get(EraVM::ADDrrr_s), ToReg)
120-
.addReg(FromReg)
119+
TII->get(EraVM::ADDrrr_s))
120+
.add(MI.getOperand(0))
121+
.add(MI.getOperand(1))
121122
.addReg(EraVM::R0)
122123
.addImm(EraVMCC::COND_NONE);
123124
LLVM_DEBUG(dbgs() << "Converting PTR_TO_INT to: "; NewMI->dump());
@@ -147,8 +148,8 @@ bool EraVMExpandPseudo::runOnMachineFunction(MachineFunction &MF) {
147148
"Immediate value is too large to fit into instruction");
148149
assert(ImmVal.getBitWidth() == 256 && "Immediate value is not 256-bit");
149150

150-
BuildMI(*MI.getParent(), &MI, MI.getDebugLoc(), TII->get(Opcode),
151-
MI.getOperand(0).getReg())
151+
BuildMI(*MI.getParent(), &MI, MI.getDebugLoc(), TII->get(Opcode))
152+
.add(MI.getOperand(0))
152153
.addCImm(ConstantInt::get(*Context, ImmVal))
153154
.addReg(EraVM::R0)
154155
.addImm(EraVMCC::COND_NONE);

0 commit comments

Comments
 (0)