1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[LoopUnrollAnalyzer] Fix a crash in analyzeLoopUnrollCost.

In some cases, when simplifying with SCEV, we might consider pointer values as
just usual integer values.  Thus, we might get a different type from what we
had originally in the map of simplified values, and hence we need to check
types before operating on the values.

This fixes PR28015.

llvm-svn: 271931
This commit is contained in:
Michael Zolotukhin 2016-06-06 19:21:40 +00:00
parent f2bdc1a6d4
commit 2b6b11a19d
2 changed files with 21 additions and 3 deletions

View File

@ -187,9 +187,11 @@ bool UnrolledInstAnalyzer::visitCmpInst(CmpInst &I) {
if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
if (Constant *CRHS = dyn_cast<Constant>(RHS)) {
if (Constant *C = ConstantExpr::getCompare(I.getPredicate(), CLHS, CRHS)) {
SimplifiedValues[&I] = C;
return true;
if (CLHS->getType() == CRHS->getType()) {
if (Constant *C = ConstantExpr::getCompare(I.getPredicate(), CLHS, CRHS)) {
SimplifiedValues[&I] = C;
return true;
}
}
}
}

View File

@ -188,3 +188,19 @@ for.inc:
for.end:
ret void
}
define void @cmp_type_mismatch() {
entry:
br label %for.header
for.header:
br label %for.body
for.body:
%d = phi i32* [ null, %for.header ]
%cmp = icmp eq i32* %d, null
br i1 undef, label %for.end, label %for.header
for.end:
ret void
}