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 tree-optimization/107212] [11/12/13 Regression] Wrong vectorizer code since r11-718-gc735929a2503a7d0
Date: Tue, 11 Oct 2022 09:30:31 +0000	[thread overview]
Message-ID: <bug-107212-4-C38hiA95jj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107212-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the speciality here is that with the SLP reduction we have the live lanes
split across the sum and the convert.  That wrecks havoc with
vectorizable_reduction following one of the lanes in the loop assigning
STMT_VINFO_REDUC_DEF to the reduction chain.  We simply do

      /* ???  For epilogue generation live members of the chain need
         to point back to the PHI via their original stmt for
         info_for_reduction to work.  */
      if (STMT_VINFO_LIVE_P (vdef))
        STMT_VINFO_REDUC_DEF (def) = phi_info;

but in this case this misses one of the paths.  Also we're not reliably
following the representative here.  Plus vectorizable_live_operation
doesn't get the representative but the actual scalar stmt defining the
live lane (on purpose).  So the fix is to make sure the above setting
of STMT_VINFO_REDUC_DEF covers all live lanes of the SLP node.  For
vectorizable_live_operation the

          else
            /* For SLP reductions the meta-info is attached to
               the representative.  */
            stmt_info = SLP_TREE_REPRESENTATIVE (slp_node);

doing is then wrong and

          /* For SLP reductions we vectorize the epilogue for
             all involved stmts together.  */
          else if (slp_index != 0)
            return true;

is also suspicious then but it seems we cope with the conversions just
fine.  So we're actually vectorizing the epilogue for the live lane 0
in the reduction chain but analysis might end up not following the lane 0
SSA use-def chain and identifying lane > 0 reductions is just to avoid
non-reduction live code gen.

  parent reply	other threads:[~2022-10-11  9:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  8:06 [Bug c/107212] New: -O2 and -O3 optimizer bug aosman9xx9 at gmail dot com
2022-10-11  8:32 ` [Bug tree-optimization/107212] [11/12/13 Regression] Wrong vectorizer code since r11-718-gc735929a2503a7d0 marxin at gcc dot gnu.org
2022-10-11  8:42 ` rguenth at gcc dot gnu.org
2022-10-11  8:43 ` rguenth at gcc dot gnu.org
2022-10-11  8:44 ` marxin at gcc dot gnu.org
2022-10-11  9:30 ` rguenth at gcc dot gnu.org [this message]
2022-10-11  9:30 ` rguenth at gcc dot gnu.org
2022-10-11 11:15 ` cvs-commit at gcc dot gnu.org
2022-10-11 11:16 ` [Bug tree-optimization/107212] [11/12 " rguenth at gcc dot gnu.org
2022-10-17 13:10 ` cvs-commit at gcc dot gnu.org
2023-01-24 15:22 ` [Bug tree-optimization/107212] [11 " cvs-commit at gcc dot gnu.org
2023-01-24 15:23 ` 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-107212-4-C38hiA95jj@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).