public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Does -floop-nest-optimize ever work usefully?
@ 2021-09-27 16:01 Dave Love
  0 siblings, 0 replies; only message in thread
From: Dave Love @ 2021-09-27 16:01 UTC (permalink / raw)
  To: gcc-help

[I don't know if this merits a bug report, but I expect there's
something worth understanding anyway.]

I'd like to have polyhedral-type optimizations available, but I've never
been able to get -floop-nest-optimize to do anything useful with various
GCC releases.  (I realize it's always been marked experimental.)  Does
it ever actually do anything other than pessimize loop nests, at least
due to stopping vectorization?  If so, what's the trick?

For instance, consider the matmul (dgemm) example from Pluto
<https://raw.githubusercontent.com/bondhugula/pluto/master/examples/matmul/matmul.c>:

  for (i = 0; i < M; i++)
    for (j = 0; j < N; j++)
      for (k = 0; k < K; k++)
        C[i][j] = beta * C[i][j] + alpha * A[i][k] * B[k][j];

If I use -Ofast -floop-nest-optimize, graphite fails:

  matmul.c:73:42: missed: failed: evolution of offset is not affine.

but there's a drastic pessimization (compared with just -Ofast):

  matmul.c:73:42: missed: couldn't vectorize loop

With -O2 -ffast-math -ftree-loop-vectorize -floop-nest-optimize it does
report the nest was optimized, but still vectorization fails, with an
extra message:

  matmul.c:73:42: missed: not vectorized: no vectype for stmt: _17 = A[_62][_61];

The above is on SKX with GCC 11, with or without -march=native.  On
ppc64le, -floop-nest-optimize didn't seem to kick in.

The results with pluto+gcc, or clang with polly, are much better than
gcc -Ofast -- they generate a five-level loop nest, with default tiling.
(I tried with xlc on ppc64le, and couldn't find a way to stop it
pattern-matching to call external dgemm...)

Thanks for any insight.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-27 16:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 16:01 Does -floop-nest-optimize ever work usefully? Dave Love

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).