define void @sle(i8* %p, i32 %a, i32 %b) { ... for.body: %i.04 = phi i32 [ %a, %for.body.lr.ph ], [ %inc, %for.body ] %inc = add nsw i32 %i.04, 1 %cmp = icmp sle i32 %inc, %b br i1 %cmp, label %for.body, label %for.end ... }
SCEV for %i.04 is {%a, +, 1}, SCEV for icmp LHS(%inc) is {(%a + 1) <nsw>, + , 1}. Currently, the range for LHS is full-set.
In patch https://reviews.llvm.org/D64869, the range for LHS is corrected to [INT32_MIN+1, INT32_MIN).
This patch is based on the fixed range in https://reviews.llvm.org/D64869 to get backedge-taken for more loops. We can convert more sle/ule to slt/ult.