[LoopUnrollAnalyzer] Fix a crash in UnrolledInstAnalyzer::visitCastInst.

This fixes PR27847. Now for real.

llvm-svn: 270629
This commit is contained in:
Michael Zolotukhin 2016-05-24 22:59:58 +00:00
parent 4caa1bf0bd
commit 7216dd4668
2 changed files with 19 additions and 5 deletions

View File

@ -141,11 +141,7 @@ bool UnrolledInstAnalyzer::visitCastInst(CastInst &I) {
Constant *COp = dyn_cast<Constant>(I.getOperand(0));
if (!COp)
COp = SimplifiedValues.lookup(I.getOperand(0));
if (COp) {
if (COp->getType() == I.getType()) {
SimplifiedValues[&I] = cast<Constant>(COp);
return true;
}
if (COp && CastInst::castIsValid(I.getOpcode(), COp, I.getType())) {
if (Constant *C =
ConstantExpr::getCast(I.getOpcode(), COp, I.getType())) {
SimplifiedValues[&I] = C;

View File

@ -119,3 +119,21 @@ for.inc:
for.cond.cleanup:
ret void
}
define void @ptrtoint_cast2() {
entry:
br i1 false, label %for.body.lr.ph, label %exit
for.body.lr.ph:
br label %for.body
for.body:
%iv = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
%offset = getelementptr inbounds float, float* null, i32 3
%bc = bitcast float* %offset to i64*
%inc = add nuw nsw i32 %iv, 1
br i1 false, label %for.body, label %exit
exit:
ret void
}