From 20d4be151b54feb18aa1e5cc04033a4aa64137ae Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 1 Jul 2010 02:58:57 +0000 Subject: [PATCH] Enable on-demand fast-isel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107377 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/FastISel.cpp | 5 ++++- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 6 ++++++ lib/Target/X86/X86FastISel.cpp | 2 +- test/CodeGen/X86/fast-isel-shift-imm.ll | 5 +++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index cc8c3c70ac2..2d6b78840f5 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -161,7 +161,10 @@ unsigned FastISel::materializeRegForValue(const Value *V, MVT VT) { } } } else if (const Operator *Op = dyn_cast(V)) { - if (!SelectOperator(Op, Op->getOpcode())) return 0; + if (!SelectOperator(Op, Op->getOpcode())) + if (!isa(Op) || + !TargetSelectInstruction(cast(Op))) + return 0; Reg = lookUpRegForValue(Op); } else if (isa(V)) { Reg = createResultReg(TLI.getRegClassFor(VT)); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 3b0ef18dd85..0848e46c0ef 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -709,6 +709,12 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) { FastIS->startNewBlock(BB); // Do FastISel on as many instructions as possible. for (; BI != End; ++BI) { + // Defer instructions with no side effects; they'll be emitted + // on-demand later. + if (BI->isSafeToSpeculativelyExecute() && + !FuncInfo->ValueMap.count(BI)) + continue; + // Try to select the instruction with FastISel. if (FastIS->SelectInstruction(BI)) continue; diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 1c700b290a6..6733f80d501 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -935,7 +935,7 @@ bool X86FastISel::X86SelectBranch(const Instruction *I) { if (CI->getIntrinsicID() == Intrinsic::sadd_with_overflow || CI->getIntrinsicID() == Intrinsic::uadd_with_overflow) { const MachineInstr *SetMI = 0; - unsigned Reg = lookUpRegForValue(EI); + unsigned Reg = getRegForValue(EI); for (MachineBasicBlock::const_reverse_iterator RI = MBB->rbegin(), RE = MBB->rend(); RI != RE; ++RI) { diff --git a/test/CodeGen/X86/fast-isel-shift-imm.ll b/test/CodeGen/X86/fast-isel-shift-imm.ll index 35f7a72a285..7759bb05689 100644 --- a/test/CodeGen/X86/fast-isel-shift-imm.ll +++ b/test/CodeGen/X86/fast-isel-shift-imm.ll @@ -1,7 +1,8 @@ ; RUN: llc < %s -march=x86 -O0 | grep {sarl \$80, %eax} ; PR3242 -define i32 @foo(i32 %x) nounwind { +define void @foo(i32 %x, i32* %p) nounwind { %y = ashr i32 %x, 50000 - ret i32 %y + store i32 %y, i32* %p + ret void } -- 2.34.1