[PATCH] D50167: RFC: [SCEV] Add explicit representations of umin/smin

Vikram TV via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 13 03:06:43 PDT 2018


tvvikram added a comment.

For some %r and an indvar %i, the SCEV for (1 + min(r - 1, i)) in smax terms is: (-1 * ((-1 * (zext i32 %r to i64))<nsw> smax {-1,+,-1}<nw><%for.outerloop>))<nsw>.
With your patch, smax gets converted to smin as: (1 + ((-1 + (zext i32 %r to i64))<nsw> smin {0,+,1}<nuw><nsw><%for.outerloop>)), which is correct.
But, it could be simplified further by distributing 1 over smin(?). I might be missing something here. Maybe your patch needs improvement or the getAddExpr() should be improved to handle smin.
P.S.: I am adding 1 explicitly in my code to the min expression i.e. SE->getAddExpr(<scevForMin>, getOne(<ty>)) in both the above cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D50167





More information about the llvm-commits mailing list