[PATCH] D43245: [LoopInterchange] Support reductions across inner and outer loop.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 31 10:41:05 PDT 2018


fhahn added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopInterchange.cpp:829
-  // Outer loop cannot have reduction because then loops will not be tightly
-  // nested.
-  if (!Reductions.empty()) {
----------------
fhahn wrote:
> efriedma wrote:
> > Given you're deleting this, is there some check that disallows interchanging if a PHI is a reduction in the outer loop, but not the inner loop?  Something like:
> > 
> > ```
> >   for( int i=1;i<N;i++) {
> >     for( int j=1;j<N;j++) {
> >       A[i][j]++;
> >     }
> >     X += j;
> >   }
> > ```
> Right!  We should keep the check and could just not add PHIs across inner and outer loop there I think
With the new structure, those kinds of loops are ruled out, because reductions in the outer loop need to have a corresponding reduction in the inner loop. I've added test/Transforms/LoopInterchange/outer-only-reductions.ll, which should show this case.


https://reviews.llvm.org/D43245





More information about the llvm-commits mailing list