fix Generic/2006-10-29-Crash.ll
authorChris Lattner <sabre@nondot.org>
Sun, 29 Oct 2006 21:01:20 +0000 (21:01 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Oct 2006 21:01:20 +0000 (21:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31281 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 6381f526f61d2407d4bdc224002fda2fdcf47e60..9794af17719c01af10e7e8a1a224d70ad5c1d532 100644 (file)
@@ -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<Instruction>(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<BinaryOperator>(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