[IRCE] Fix misuse of dyn_cast which leads to UB

llvm-svn: 331508
This commit is contained in:
Max Kazantsev 2018-05-04 07:34:35 +00:00
parent 47e6b8c2c7
commit 786032c1b7
1 changed files with 3 additions and 2 deletions

View File

@ -925,11 +925,12 @@ LoopStructure::parseLoopStructure(ScalarEvolution &SE,
return None;
}
const SCEV* StepRec = IndVarBase->getStepRecurrence(SE);
ConstantInt *StepCI = dyn_cast<SCEVConstant>(StepRec)->getValue();
if (!StepCI) {
if (!isa<SCEVConstant>(StepRec)) {
FailureReason = "LHS in icmp not induction variable";
return None;
}
ConstantInt *StepCI = cast<SCEVConstant>(StepRec)->getValue();
if (ICI->isEquality() && !HasNoSignedWrap(IndVarBase)) {
FailureReason = "LHS in icmp needs nsw for equality predicates";
return None;