From 4ecbca558f8ee558dd0e84e079f16528fd9768f2 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 9 Mar 2010 23:46:50 +0000 Subject: Avoid analyzing instructions in blocks not reachable from the entry block. They are lots of trouble, and they don't matter. This fixes PR6559. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98103 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolution.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index b979f3328d..15f072dbeb 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -3101,9 +3101,16 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { return getUnknown(V); unsigned Opcode = Instruction::UserOp1; - if (Instruction *I = dyn_cast(V)) + if (Instruction *I = dyn_cast(V)) { Opcode = I->getOpcode(); - else if (ConstantExpr *CE = dyn_cast(V)) + + // Don't attempt to analyze instructions in blocks that aren't + // reachable. Such instructions don't matter, and they aren't required + // to obey basic rules for definitions dominating uses which this + // analysis depends on. + if (!DT->isReachableFromEntry(I->getParent())) + return getUnknown(V); + } else if (ConstantExpr *CE = dyn_cast(V)) Opcode = CE->getOpcode(); else if (ConstantInt *CI = dyn_cast(V)) return getConstant(CI); -- cgit v1.2.3-70-g09d2