From 6f34b43292fe478b28ac4b1c6f7c0162cda71c5f Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 8 Sep 2006 21:08:13 +0000 Subject: [PATCH] Fixed a FuseTwoAddrInst() bug: consider GlobalAddress and JumpTableIndex in addition to immediate operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30205 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86RegisterInfo.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index 037220adbbe..40d7a6c3834 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -169,12 +169,17 @@ static MachineInstr *FuseTwoAddrInst(unsigned Opcode, unsigned FrameIndex, // Loop over the rest of the ri operands, converting them over. for (unsigned i = 0; i != NumOps; ++i) { - if (MI->getOperand(i+2).isReg()) - MIB = MIB.addReg(MI->getOperand(i+2).getReg()); - else { - assert(MI->getOperand(i+2).isImm() && "Unknown operand type!"); - MIB = MIB.addImm(MI->getOperand(i+2).getImm()); - } + MachineOperand &MO = MI->getOperand(i+2); + if (MO.isReg()) + MIB = MIB.addReg(MO.getReg()); + else if (MO.isImm()) + MIB = MIB.addImm(MO.getImm()); + else if (MO.isGlobalAddress()) + MIB = MIB.addGlobalAddress(MO.getGlobal(), MO.getOffset()); + else if (MO.isJumpTableIndex()) + MIB = MIB.addJumpTableIndex(MO.getJumpTableIndex()); + else + assert(0 && "Unknown operand type!"); } return MIB; }