[Polly] Isl AST reduction pragmas [V2]

Tobias Grosser tobias at grosser.es
Wed Jun 18 22:27:06 PDT 2014


On 19/06/2014 03:00, Johannes Doerfert wrote:
> Hey Tobi,
>
> I cannot come up with a test case which contains a reduction and will be
> inverted.
>
> I tried combinations of loop nest similar to your example, but no luck so
> far.
> Handling this case would be a nice improvement, but do we need it right now
> or can we go with the simpler solution which is slightly less general?

void foo(float *A, long n) {

         for (long i = 0; i < n; i++)
                 A[i] = 1;
         for (long i = 0; i < 2*n; i++)
                 A[2*n-i-1] += 1;
}

Compiled with polly-clang /tmp/test.c -mllvm -polly -O3 -mllvm 
-debug-only=polly-cloog -c -mllvm -polly-opt-fusion=max yields:

:: foo : entry.split => for.end10
if (n >= 1) {
   for (c1=1;c1<=n;c1++) {
     Stmt_for_body((c1-1));
     Stmt_for_body4((-c1+2*n));
   }
   for (c1=n+1;c1<=2*n;c1++) {
     Stmt_for_body4((-c1+2*n));
   }
}

The second loop nest will now have negative reduction dependences, no?

As dependences are generally supposed to be positive, I believe it is an 
issue that a simple test may introduce negative dependences. So we 
either need to convince ourselves that negative dependences will never 
ever cause any issue, or we just adjust/recompute them after computing a 
new schedule. I believe the second option is easier for now.

Tobias

Tobias



More information about the llvm-commits mailing list