Bug 43543

Summary: Reorder the statements in the loop can vectorize it
Product: gcc Reporter: Changpeng Fang <changpeng.fang>
Component: tree-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: enhancement CC: gcc-bugs
Priority: P3 Keywords: missed-optimization
Version: 4.5.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2016-08-14 00:00:00
Bug Depends on:    
Bug Blocks: 53947    

Description Changpeng Fang 2010-03-26 17:58:53 UTC
int a[100], b[100], c[100], d[100];

void foo ()
{
  int i;
  for(i=1; i< 99; i++)
  {
    a[i] = b[i-1] + c[i];
    b[i] = b[i+1] + d[i];
  }
}

gcc -O3 -ffast-math -ftree-vectorizer-verbose=2 -c foo.c

foo.c:6: note: not vectorized, possible dependence between data-refs b[D.2728_3] and b[i_17]
foo.c:3: note: vectorized 0 loops in function.

However, if we reorder the two statements in the loop, then it can be vectorized. open64 can do this reordering.
Comment 1 Ira Rosen 2010-03-28 11:16:31 UTC
Looks similar to PR 32806.
Comment 2 Drea Pinski 2016-08-14 18:51:17 UTC
Confirmed.