From 13a5dcddceca452d1dcc8c964d6c28c27ad025c1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 5 Sep 2006 02:12:02 +0000 Subject: Fix a long-standing wart in the code generator: two-address instruction lowering actually *removes* one of the operands, instead of just assigning both operands the same register. This make reasoning about instructions unnecessarily complex, because you need to know if you are before or after register allocation to match up operand #'s with the target description file. Changing this also gets rid of a bunch of hacky code in various places. This patch also includes changes to fold loads into cmp/test instructions in the X86 backend, along with a significant simplification to the X86 spill folding code. llvm-svn: 30108 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/TwoAddressInstructionPass.cpp') diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index f1e41d21de1..7db9958bc00 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -206,9 +206,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { } } - assert(mi->getOperand(0).isDef()); - mi->getOperand(0).setUse(); - mi->RemoveOperand(1); + assert(mi->getOperand(0).isDef() && mi->getOperand(1).isUse()); + mi->getOperand(1).setReg(mi->getOperand(0).getReg()); MadeChange = true; DEBUG(std::cerr << "\t\trewrite to:\t"; mi->print(std::cerr, &TM)); -- cgit v1.2.3