[PATCH] D154069: [IRCE] Parse range checks in the form of "LHS - RHS vs Limit"

Aleksandr Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 02:41:04 PDT 2023


aleksandr.popov added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:474
+  if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) {
+    // "Expr <= Limit" -> "Expr < Limit + 1"
+    if (Pred == ICmpInst::ICMP_SLE && Limit)
----------------
aleksandr.popov wrote:
> skatkov wrote:
> > what if you did not scale and Limit == S_INT_MAX? Limit + 1 will overflow then?
> Then we will scale Limit + 1, if we can't prove that if doesn't overflow
I've added 2 tests:
* In first one we have IV < N + 2;
* in the second one we have IV <= N + 2;
In both cases 8-bit N < 126.

In the first example we can prove that (N + 2) will not overflow and we don't scale.
In the second one we are adding 1 to the (N + 2), since predicate is not-strict. Afterwards no-overflow becomes unprovable and we scale.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154069/new/

https://reviews.llvm.org/D154069



More information about the llvm-commits mailing list