public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102160] New: Too many runtime alias checks when vectorizing
@ 2021-09-01 12:15 rguenth at gcc dot gnu.org
  2021-09-01 12:25 ` [Bug tree-optimization/102160] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-01 12:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102160

            Bug ID: 102160
           Summary: Too many runtime alias checks when vectorizing
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

The following is reduced from (or rather "inspired") 507.cactuBSSN_r
ML_BSSN_Advect_Body where, when one works around other issues by editing the
source, the vectorizer intends to create > 8000 runtime alias checks (and
refuses).

void foo (double *a, double *b, int off, int n, int m)
{
  for (int j = 0; j < m; ++j)
    for (int i = 0; i < n; ++i)
      a[j*n+i] = b[j*n+i] + b[(j+1)*n+i] + b[(j-1)*n+i];
}

this small example iterates over a 2d array in a linearized way
(and a way that as written does not actually guarantee that each
a[j*n + i] is only written once, that is, the 2 dimensions do not "overlap").

The interesting bit is that the kernel offsets the accesses in the outer loop
iteration direction and thus when analyzing the refs in the innermost loop
we have three unknown non-constant offsets to b[] and we will create three
runtime alias checks that fail to merge (obviously).

We need to do better by formulating the alias checks with respect to the
outermost [interesting] iteration where we should be able to merge the
checks into one, obviously making it less precise by computing the access
extent of the whole loop nest.

As additional benefit the runtime alias check can be hoisted and thus
versioning applied to the outer loop.  That might already magically
work even.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/102160] Too many runtime alias checks when vectorizing
  2021-09-01 12:15 [Bug tree-optimization/102160] New: Too many runtime alias checks when vectorizing rguenth at gcc dot gnu.org
@ 2021-09-01 12:25 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-01 12:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102160

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
CCing Richard who might have thoughts on this as well.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-01 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 12:15 [Bug tree-optimization/102160] New: Too many runtime alias checks when vectorizing rguenth at gcc dot gnu.org
2021-09-01 12:25 ` [Bug tree-optimization/102160] " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).