public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/104912] [12 Regression] 416.gamess regression after r12-7612-g69619acd8d9b58
Date: Mon, 14 Mar 2022 13:49:13 +0000	[thread overview]
Message-ID: <bug-104912-4-CafyyBLbYA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104912-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think for the case at hand no runtime alias checking is needed, since we have

            DO 30 MK=1,NOC
            DO 30 ML=1,MK
               MKL = MKL+1
               XPQKL(MPQ,MKL) = XPQKL(MPQ,MKL) +
     *               VAL1*(CO(MS,MK)*CO(MR,ML)+CO(MS,ML)*CO(MR,MK))
               XPQKL(MRS,MKL) = XPQKL(MRS,MKL) +
     *               VAL3*(CO(MQ,MK)*CO(MP,ML)+CO(MQ,ML)*CO(MP,MK))
   30       CONTINUE

so we're dealing with reductions which we can interleave (with -Ofast). 
Editing
the source with !GCC$ ivdep reduces the vectorization penalty to 5% (we still
need the niter/epilogue checks).  It also shows that only fixing PR89755 isn't
the solution we're looking for.

In the end the vectorization is unlikely going to play out since V2DF is
usually handled well by dual issue capabilities for DFmode arithmetic on
modern archs.

The only mitigation I can think of is realizing the outer inner loop niter
is 0, 1, 2, .., NOC - 1 and thus the first outer iterations will have inner
loop vectorization not profitable.  But the question is what to do with this
(not knowing the actual runtime values of NOC).  As PR87561 says

"Note for 416.gamess it looks like NOC is just 5 but MPQ and MRS are so
that there is no runtime aliasing between iterations most of the time
(sometimes they are indeed equal).  The cost model check skips the
vector loop for MK == 2 and 3 and only will execute it for MK == 4 and 5.
An alternative for this kind of loop nest would be to cost-model for
MK % 2 == 0, thus requiring no epilogue loop."

In general applying no vectorization to these kind of loops looks wrong.
Versioning also the outer loop in addition to the inner loop in case the
number of iterations evolves in the outer loop looks excessive (but would
eventually help 416.gamess).  Implementation-wise it's also non-trivial.

  parent reply	other threads:[~2022-03-14 13:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 11:06 [Bug target/104912] New: [12 Regression] 416.gamess regression after r12-7612 rguenth at gcc dot gnu.org
2022-03-14 11:06 ` [Bug target/104912] " rguenth at gcc dot gnu.org
2022-03-14 11:55 ` [Bug target/104912] [12 Regression] 416.gamess regression after r12-7612-g69619acd8d9b58 rguenth at gcc dot gnu.org
2022-03-14 11:58 ` rguenth at gcc dot gnu.org
2022-03-14 12:17 ` rguenth at gcc dot gnu.org
2022-03-14 13:49 ` rguenth at gcc dot gnu.org [this message]
2022-03-14 14:25 ` rguenth at gcc dot gnu.org
2022-03-17 12:31 ` rguenth at gcc dot gnu.org
2022-03-21 13:08 ` rguenth at gcc dot gnu.org
2022-04-13  7:54 ` cvs-commit at gcc dot gnu.org
2022-04-13  8:02 ` rguenth at gcc dot gnu.org
2022-04-20 11:28 ` cvs-commit at gcc dot gnu.org
2022-05-06  8:33 ` [Bug target/104912] [12/13 " jakub at gcc dot gnu.org
2022-07-26 12:42 ` rguenth at gcc dot gnu.org
2023-01-31 11:22 ` jamborm at gcc dot gnu.org
2023-01-31 12:02 ` rguenth at gcc dot gnu.org
2023-05-08 12:24 ` [Bug target/104912] [12/13/14 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104912-4-CafyyBLbYA@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).