Bug 43543 - Reorder the statements in the loop can vectorize it
Summary: Reorder the statements in the loop can vectorize it
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: missed-optimization
Depends on:
Blocks: vectorizer
  Show dependency treegraph
Reported: 2010-03-26 17:58 UTC by Changpeng Fang
Modified: 2021-08-24 23:59 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2016-08-14 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
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 Andrew Pinski 2016-08-14 18:51:17 UTC