[llvm-dev] Canonicalize induction variables
Ehsan Amiri via llvm-dev
llvm-dev at lists.llvm.org
Thu Aug 25 12:43:51 PDT 2016
Does the fact that loop vectorizer supports arbitrary constant step size
suggest that this is by design?
https://reviews.llvm.org/rL227557
Apparently an older version of LLVM, canonicalized induction variables as
described above.
http://llvm.org/releases/2.6/docs/Passes.html#indvars
On Wed, Aug 24, 2016 at 9:48 PM, Yaoqing Gao via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> I just subscribed this group. This is my first time to post a question
> (not sure if this is a right place for discussion) after I have a brief
> look at LLVM OPT (dev trunk). I would expect loop simplification and
> induction variable canonicalization pass (IndVarSimplify pass) should be
> able to convert the following loops into a simple canonical form, i.e.,
> there is a canonical induction variable which starts at zero and steps by
> one, getCanonicalInductionVariable() returns the first PHI node in the
> loop header block.
>
> int test1 (int x[], int k, int s) {
> int sum = 0;
> for (int i = 0; i < k; i+=s) {
> sum += x[i];
> }
> return sum;
> }
>
> int test2(int x[], int k, int s) {
> int sum = 0;
> for (int i = k; i > 0; i--) {
> sum += x[i];
> }
> return sum;
> }
>
> Anyone can help explain why the current LLVM cannot canonicalize induction
> variables for the above loops (by design or a limitation to be fixed in the
> future)? Thanks.
>
> --
> Best regards,
>
> Yaoqing Gao
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160825/ab4431ae/attachment.html>
More information about the llvm-dev
mailing list