When using MachineInstr operand indices on SDNodes, the number

of MachineInstr def operands must be subtracted out. This bug
was uncovered by the recent x86 EFLAGS optimization. Before
that, the only instructions that ever needed unfolding were
things like CMP32rm, where NumDefs is zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66056 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-03-04 19:23:38 +00:00
parent 88fe1ad187
commit b37a8206b6

View File

@@ -2382,6 +2382,7 @@ X86InstrInfo::unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
const TargetOperandInfo &TOI = TID.OpInfo[Index]; const TargetOperandInfo &TOI = TID.OpInfo[Index];
const TargetRegisterClass *RC = TOI.isLookupPtrRegClass() const TargetRegisterClass *RC = TOI.isLookupPtrRegClass()
? RI.getPointerRegClass() : RI.getRegClass(TOI.RegClass); ? RI.getPointerRegClass() : RI.getRegClass(TOI.RegClass);
unsigned NumDefs = TID.NumDefs;
std::vector<SDValue> AddrOps; std::vector<SDValue> AddrOps;
std::vector<SDValue> BeforeOps; std::vector<SDValue> BeforeOps;
std::vector<SDValue> AfterOps; std::vector<SDValue> AfterOps;
@@ -2389,11 +2390,11 @@ X86InstrInfo::unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
unsigned NumOps = N->getNumOperands(); unsigned NumOps = N->getNumOperands();
for (unsigned i = 0; i != NumOps-1; ++i) { for (unsigned i = 0; i != NumOps-1; ++i) {
SDValue Op = N->getOperand(i); SDValue Op = N->getOperand(i);
if (i >= Index && i < Index+4) if (i >= Index-NumDefs && i < Index-NumDefs+4)
AddrOps.push_back(Op); AddrOps.push_back(Op);
else if (i < Index) else if (i < Index-NumDefs)
BeforeOps.push_back(Op); BeforeOps.push_back(Op);
else if (i > Index) else if (i > Index-NumDefs)
AfterOps.push_back(Op); AfterOps.push_back(Op);
} }
SDValue Chain = N->getOperand(NumOps-1); SDValue Chain = N->getOperand(NumOps-1);