diff options
| author | Michael Zolotukhin <mzolotukhin@apple.com> | 2016-06-06 19:21:40 +0000 |
|---|---|---|
| committer | Michael Zolotukhin <mzolotukhin@apple.com> | 2016-06-06 19:21:40 +0000 |
| commit | 19edbadfc5a65ba30c0fc71fbd9570567dfaf9de (patch) | |
| tree | 7f831f2a88cad29de560564f704f6be6c4b77bf0 /llvm/lib/Analysis | |
| parent | 9ed77af89dd37d72da8f804727dc0de2f37a06e9 (diff) | |
| download | bcm5719-llvm-19edbadfc5a65ba30c0fc71fbd9570567dfaf9de.tar.gz bcm5719-llvm-19edbadfc5a65ba30c0fc71fbd9570567dfaf9de.zip | |
[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
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/LoopUnrollAnalyzer.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp b/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp index f9e02078501..b13f63176fc 100644 --- a/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp +++ b/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp @@ -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; + } } } } |

