for (i=0; i<N; i++)
{
  D[i] = A[i] + Y;
  A[i+1] = B[i] + X;
}

Even though, this loop contains a backward-carried dependence between A[i+1]
and A[i], it is vectorizable  - the stmts of the loop should be interchanged to
get:

for (i=0; i<N; i++)
{
  A[i+1] = B[i] + X;
  D[i] = A[i] + Y;
}

which will be vectorizable once the pacth in PR 32377 (comment #14) is
committed. 

The interchange is possible since there is no loop-independent dependence
between the stmts. This requires working with a dependence graph when
vectorizing, or have a separate optimization before the vectorizer to take care
of this.

Ira


-- 
           Summary: Missing optimization to remove backword dependencies
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: irar at il dot ibm dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32806

Reply via email to