diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index f007b28a5d6..e30be1b41ac 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -369,17 +369,11 @@ bool X86DAGToDAGISel::SelectAddr(SDOperand N, SDOperand &Base, SDOperand &Scale, return false; if (AM.BaseType == X86ISelAddressMode::RegBase) { - if (AM.Base.Reg.Val) { - if (AM.Base.Reg.getOpcode() != ISD::Register) - AM.Base.Reg = Select(AM.Base.Reg); - } else { + if (!AM.Base.Reg.Val) AM.Base.Reg = CurDAG->getRegister(0, MVT::i32); - } } - if (AM.IndexReg.Val) - AM.IndexReg = Select(AM.IndexReg); - else + if (!AM.IndexReg.Val) AM.IndexReg = CurDAG->getRegister(0, MVT::i32); getAddressOperands(AM, Base, Scale, Index, Disp); @@ -441,11 +435,6 @@ bool X86DAGToDAGISel::SelectLEAAddr(SDOperand N, SDOperand &Base, return false; } - if (SelectBase) - AM.Base.Reg = Select(AM.Base.Reg); - if (SelectIndex) - AM.IndexReg = Select(AM.IndexReg); - getAddressOperands(AM, Base, Scale, Index, Disp); return true; } @@ -461,6 +450,11 @@ SDOperand X86DAGToDAGISel::Select(SDOperand N) { if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER) return N; // Already selected. + // These are probably emitted by SelectAddr(). + if (Opcode == ISD::TargetConstant || Opcode == ISD::TargetConstantPool || + Opcode == ISD::TargetFrameIndex || Opcode == ISD::TargetGlobalAddress) + return N; + std::map::iterator CGMI = CodeGenMap.find(N); if (CGMI != CodeGenMap.end()) return CGMI->second; diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index b85ee8c64cc..0b3d6df0d1f 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -2136,6 +2136,11 @@ public: for (unsigned i = 0; i < NumRes; i++) Code += ", Tmp" + utostr(i + ResNo); emitCheck(Code + ")"); + + for (unsigned i = 0; i < NumRes; ++i) + emitCode("Tmp" + utostr(i+ResNo) + " = Select(Tmp" + + utostr(i+ResNo) + ");"); + TmpNo = ResNo + NumRes; } else { emitCode("SDOperand Tmp" + utostr(ResNo) + " = Select(" + Val + ");");