Bug 101450 - GCC doesn't vectorize loop due to evolution of base is not affine.
Summary: GCC doesn't vectorize loop due to evolution of base is not affine.
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: vectorizer
  Show dependency treegraph
 
Reported: 2021-07-14 12:08 UTC by Hongtao.liu
Modified: 2021-07-14 12:48 UTC (History)
0 users

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-07-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hongtao.liu 2021-07-14 12:08:25 UTC
the testcase is extracted from coremark

cat test.c

void
matrix_add_const(unsigned int N, short *A, short val)
{
  unsigned int i, j;
  for (i = 0; i < N; i++)
    {
      for (j = 0; j < N; j++)
        {
	  A[i * N + j] += val;
        }
    }
}

gcc failed to vectorize it since there could be wrap for i*N + j, but we can do multi-versioning for it?

llvm seems does that.

https://godbolt.org/z/Er44ffTE3
Comment 1 Richard Biener 2021-07-14 12:48:54 UTC
Yes, as I said in some other PRs the SCEV framework would need to be extended to track 'assumptions' under which its result would be valid, much like niter analysis does.  Currently it simply gives up here.  Of course 'assumptions'
would need support from quite some mid-stream infrastructure and some way
to carry it since currently a SCEV is a tree expression.

Thus it's quite some work to do this.

The mid-stream users is mostly data dependence analysis.

There's effective duplicates of this bug.