<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115755>115755</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV][LV] LoopVectorize crashed with assertion failure when enabling EVL vectorization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mshockwave
</td>
</tr>
</table>
<pre>
The EVL LoopVectorizer currently crashes on multiple SPEC2006INT benchmarks with the same assertion failures:
```
lib/Transforms/Vectorize/LoopVectorize.cpp:2501: void llvm::InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *): Assertion `!isIndvarOverflowCheckKnownFalse(Cost, VF * UF) && !SE.isKnownPredicate(CmpInst::getInversePredicate(ICmpInst::ICMP_ULT), TC2OverflowSCEV, SE.getSCEV(Step)) && "unexpectedly proved overflow check to be known"' failed.
```
Here is a reproducer from 401.bzip2:
``` llvm
; ModuleID = 'reduced.bc'
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"
; Function Attrs: vscale_range(2,2)
define i32 @BZ2_decompress(ptr %s, i32 %0) #0 {
entry:
br label %for.cond1443
for.cond1443: ; preds = %for.body1447, %entry
%v1442.08 = phi i8 [ %inc1451, %for.body1447 ], [ 0, %entry ]
%conv1444 = zext i8 %v1442.08 to i32
%cmp1445 = icmp sgt i32 %0, %conv1444
br i1 %cmp1445, label %for.body1447, label %while.cond1462
for.body1447: ; preds = %for.cond1443
store i8 0, ptr %s, align 1
%inc1451 = add i8 %v1442.08, 1
br label %for.cond1443
while.cond1462: ; preds = %while.cond1462, %for.cond1443
br label %while.cond1462
}
attributes #0 = { vscale_range(2,2) }
```
And here is the reproducing command:
```
opt -mcpu=sifive-p670 -O3 -prefer-predicate-over-epilogue=predicate-dont-vectorize input.ll
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llv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