diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-21 02:32:36 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-21 02:32:36 +0000 |
commit | 8bef744518e5904b77ad903d6f05241f9f807a97 (patch) | |
tree | 0b8394a57b205bb71c9c283b151a2faf660f13ed /lib/Target/X86/X86FastISel.cpp | |
parent | bf8154a4395bf941f57f6453503a850cb9805a64 (diff) | |
download | external_llvm-8bef744518e5904b77ad903d6f05241f9f807a97.zip external_llvm-8bef744518e5904b77ad903d6f05241f9f807a97.tar.gz external_llvm-8bef744518e5904b77ad903d6f05241f9f807a97.tar.bz2 |
Fix x86 fast-isel's cmp+branch folding to avoid folding when the
comparison is in a different basic block from the branch. In such
cases, the comparison's operands may not have initialized virtual
registers available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111709 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86FastISel.cpp')
-rw-r--r-- | lib/Target/X86/X86FastISel.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index b7341f9..0c70eec 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -960,9 +960,11 @@ bool X86FastISel::X86SelectBranch(const Instruction *I) { MachineBasicBlock *TrueMBB = FuncInfo.MBBMap[BI->getSuccessor(0)]; MachineBasicBlock *FalseMBB = FuncInfo.MBBMap[BI->getSuccessor(1)]; - // Fold the common case of a conditional branch with a comparison. + // Fold the common case of a conditional branch with a comparison + // in the same block (values defined on other blocks may not have + // initialized registers). if (const CmpInst *CI = dyn_cast<CmpInst>(BI->getCondition())) { - if (CI->hasOneUse()) { + if (CI->hasOneUse() && CI->getParent() == I->getParent()) { EVT VT = TLI.getValueType(CI->getOperand(0)->getType()); // Try to take advantage of fallthrough opportunities. |