merge two loops over all nodes in the graph into one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97606 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-03-02 23:12:51 +00:00
parent 98d45790ae
commit fb444af5c9

View File

@@ -207,9 +207,6 @@ namespace {
SDValue &Index, SDValue &Disp, SDValue &Index, SDValue &Disp,
SDValue &Segment); SDValue &Segment);
void PreprocessForCallLoads();
void PreprocessForFPConvert();
/// SelectInlineAsmMemoryOperand - Implement addressing mode selection for /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
/// inline asm expressions. /// inline asm expressions.
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
@@ -415,13 +412,14 @@ static bool isCalleeLoad(SDValue Callee, SDValue &Chain) {
return false; return false;
} }
void X86DAGToDAGISel::PreprocessISelDAG() {
OptForSize = MF->getFunction()->hasFnAttr(Attribute::OptimizeForSize);
void X86DAGToDAGISel::PreprocessForCallLoads() {
for (SelectionDAG::allnodes_iterator I = CurDAG->allnodes_begin(), for (SelectionDAG::allnodes_iterator I = CurDAG->allnodes_begin(),
E = CurDAG->allnodes_end(); I != E; ++I) { E = CurDAG->allnodes_end(); I != E; ) {
if (I->getOpcode() != X86ISD::CALL) SDNode *N = I++; // Preincrement iterator to avoid invalidation issues.
continue;
if (OptLevel != CodeGenOpt::None && N->getOpcode() == X86ISD::CALL) {
/// Also try moving call address load from outside callseq_start to just /// Also try moving call address load from outside callseq_start to just
/// before the call to allow it to be folded. /// before the call to allow it to be folded.
/// ///
@@ -441,28 +439,23 @@ void X86DAGToDAGISel::PreprocessForCallLoads() {
/// \ / /// \ /
/// \ / /// \ /
/// [CALL] /// [CALL]
SDValue Chain = I->getOperand(0); SDValue Chain = N->getOperand(0);
SDValue Load = I->getOperand(1); SDValue Load = N->getOperand(1);
if (!isCalleeLoad(Load, Chain)) if (!isCalleeLoad(Load, Chain))
continue; continue;
MoveBelowCallSeqStart(CurDAG, Load, SDValue(I, 0), Chain); MoveBelowCallSeqStart(CurDAG, Load, SDValue(N, 0), Chain);
++NumLoadMoved; ++NumLoadMoved;
continue;
} }
}
// Lower fpround and fpextend nodes that target the FP stack to be store and
/// PreprocessForFPConvert - Walk over the dag lowering fpround and fpextend // load to the stack. This is a gross hack. We would like to simply mark
/// nodes that target the FP stack to be store and load to the stack. This is a // these as being illegal, but when we do that, legalize produces these when
/// gross hack. We would like to simply mark these as being illegal, but when // it expands calls, then expands these in the same legalize pass. We would
/// we do that, legalize produces these when it expands calls, then expands // like dag combine to be able to hack on these between the call expansion
/// these in the same legalize pass. We would like dag combine to be able to // and the node legalization. As such this pass basically does "really
/// hack on these between the call expansion and the node legalization. As such // late" legalization of these inline with the X86 isel pass.
/// this pass basically does "really late" legalization of these inline with the // FIXME: This should only happen when not compiled with -O0.
/// X86 isel pass.
void X86DAGToDAGISel::PreprocessForFPConvert() {
for (SelectionDAG::allnodes_iterator I = CurDAG->allnodes_begin(),
E = CurDAG->allnodes_end(); I != E; ) {
SDNode *N = I++; // Preincrement iterator to avoid invalidation issues.
if (N->getOpcode() != ISD::FP_ROUND && N->getOpcode() != ISD::FP_EXTEND) if (N->getOpcode() != ISD::FP_ROUND && N->getOpcode() != ISD::FP_EXTEND)
continue; continue;
@@ -518,15 +511,6 @@ void X86DAGToDAGISel::PreprocessForFPConvert() {
} }
} }
void X86DAGToDAGISel::PreprocessISelDAG() {
OptForSize = MF->getFunction()->hasFnAttr(Attribute::OptimizeForSize);
if (OptLevel != CodeGenOpt::None)
PreprocessForCallLoads();
// FIXME: This should only happen when not compiled with -O0.
PreprocessForFPConvert();
}
/// EmitSpecialCodeForMain - Emit any code that needs to be executed only in /// EmitSpecialCodeForMain - Emit any code that needs to be executed only in
/// the main function. /// the main function.