From e60ae823e86bfa2dd1935a7a1d3fe3d6b3b457fa Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 29 Oct 2006 21:01:20 +0000 Subject: [PATCH] fix Generic/2006-10-29-Crash.ll llvm-svn: 31281 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 6381f526f61d..9794af17719c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -824,6 +824,12 @@ bool SelectionDAGLowering::isExportableFromCurrentBlock(Value *V, return true; } +static bool InBlock(const Value *V, const BasicBlock *BB) { + if (const Instruction *I = dyn_cast(V)) + return I->getParent() == BB; + return true; +} + /// FindMergedConditions - If Cond is an expression like void SelectionDAGLowering::FindMergedConditions(Value *Cond, MachineBasicBlock *TBB, @@ -834,7 +840,9 @@ void SelectionDAGLowering::FindMergedConditions(Value *Cond, BinaryOperator *BOp = dyn_cast(Cond); if (!BOp || (unsigned)BOp->getOpcode() != Opc || !BOp->hasOneUse() || - BOp->getParent() != CurBB->getBasicBlock()) { + BOp->getParent() != CurBB->getBasicBlock() || + !InBlock(BOp->getOperand(0), CurBB->getBasicBlock()) || + !InBlock(BOp->getOperand(1), CurBB->getBasicBlock())) { const BasicBlock *BB = CurBB->getBasicBlock(); // If the leaf of the tree is a setcond inst, merge the condition into the