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 middle-end/113205] [14 Regression] internal compiler error: in backward_pass, at tree-vect-slp.cc:5346 since r14-3220
Date: Wed, 10 Jan 2024 08:12:45 +0000	[thread overview]
Message-ID: <bug-113205-4-5AoQyZWXYF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113205-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=110935

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so this should already reproduce before the change when removing the
invariant add (p + 8000).  The issue seems to be that SLP build ends up
with an unsupported load permutation when we try with V2SImode vectorization
after V4SImode is scrapped because of cost issues.  We have

t.c:18:10: note:   node 0x6471a48 (max_nunits=2, refcnt=2) vector(2) int
t.c:18:10: note:   op template: _3 = MEM[(int *)i.0_1 + 4B];
t.c:18:10: note:        stmt 0 _3 = MEM[(int *)i.0_1 + 4B];
t.c:18:10: note:        stmt 1 _5 = MEM[(int *)i.0_1 + 12B];
t.c:18:10: note:        stmt 2 _4 = MEM[(int *)i.0_1 + 8B];
t.c:18:10: note:        stmt 3 _2 = *i.0_1;
t.c:18:10: note:        load permutation { 1 3 2 0 }

I'm not sure whether that's a supported situation.  Changing the code
to be more graceful like

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index b6cce55ce90..a12214bc1ad 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -5343,8 +5343,8 @@ vect_optimize_slp_pass::backward_pass ()
            }
        }

-      gcc_assert (min_layout_cost.is_possible ());
-      partition.layout = min_layout_i;
+      if (min_layout_cost.is_possible ())
+       partition.layout = min_layout_i;
     }
 }

then yields

t.c:18:10: note:  SLP optimize permutations:
t.c:18:10: note:    1: { 1, 3, 2, 0 }
t.c:18:10: note:  SLP optimize partitions:
t.c:18:10: note:    -------------
t.c:18:10: note:    partition 0 (layout 0):
t.c:18:10: note:      nodes:
t.c:18:10: note:        - 0x5f0d9b0:
t.c:18:10: note:            weight: 1.000000
t.c:18:10: note:            out weight: 1.000000 (degree 1)
t.c:18:10: note:            op template: _20 = (int) _19;
t.c:18:10: note:      edges:
t.c:18:10: note:        - 0x5f0d9b0 --> [2] 0x5f0d928
t.c:18:10: note:      layout 0: rejected
t.c:18:10: note:      layout 1: rejected
t.c:18:10: note:    -------------
t.c:18:10: note:    partition 1 (layout 1):
t.c:18:10: note:      nodes:
t.c:18:10: note:        - 0x5f0da38:
t.c:18:10: note:            weight: 1.000000
t.c:18:10: note:            out weight: 1.000000 (degree 1)
t.c:18:10: note:            op template: _3 = MEM[(int *)i.0_1 + 4B];
t.c:18:10: note:      edges:
t.c:18:10: note:        - 0x5f0da38 --> [2] 0x5f0d928
t.c:18:10: note:      layout 0: rejected
t.c:18:10: note:      layout 1: rejected
t.c:18:10: note:    -------------
t.c:18:10: note:    partition 2 (layout 1):
t.c:18:10: note:      nodes:
t.c:18:10: note:        - 0x5f0d928:
t.c:18:10: note:            weight: 1.000000
t.c:18:10: note:            out weight: 1.000000 (degree 1)
t.c:18:10: note:            op template: _21 = _3 * _20;
t.c:18:10: note:      edges:
t.c:18:10: note:        - 0x5f0d928 --> [3] 0x5f0d8a0
t.c:18:10: note:        - 0x5f0d9b0 [0] --> 0x5f0d928
t.c:18:10: note:        - 0x5f0da38 [1] --> 0x5f0d928
t.c:18:10: note:      layout 0: rejected
t.c:18:10: note:      layout 1: rejected
t.c:18:10: note:    -------------
t.c:18:10: note:    partition 3 (layout 1):
t.c:18:10: note:      nodes:
t.c:18:10: note:        - 0x5f0d8a0:
t.c:18:10: note:            weight: 1.000000
t.c:18:10: note:            op template: _22 = (unsigned int) _21;
t.c:18:10: note:      edges:
t.c:18:10: note:        - 0x5f0d928 [2] --> 0x5f0d8a0
t.c:18:10: note:      layout 0:
t.c:18:10: note:          {depth: 1.000000, total: 1.000000}
t.c:18:10: note:        + {depth: 0.000000, total: 0.000000}
t.c:18:10: note:        + {depth: 0.000000, total: 0.000000}
t.c:18:10: note:        = {depth: 1.000000, total: 1.000000}
t.c:18:10: note:      layout 1: (*)
t.c:18:10: note:          {depth: 0.000000, total: 0.000000}
t.c:18:10: note:        + {depth: 0.000000, total: 0.000000}
t.c:18:10: note:        + {depth: 0.000000, total: 0.000000}
t.c:18:10: note:        = {depth: 0.000000, total: 0.000000}
t.c:18:10: note:  inserting permutation node in place of 0x5f0d9b0
t.c:18:10: note:  recording new base alignment for i.0_1
...
t.c:18:10: note:   vectorizing permutation op0[3] op0[0] op0[2] op0[1]
t.c:18:10: note:   vectorizing permutation op0[3] op0[0] op0[2] op0[1]
t.c:18:10: note:   as vops0[1][1] vops0[0][0], vops0[1][0] vops0[0][1]
t.c:18:10: missed:   unsupported vect permute { 1 2 }
t.c:18:10: note:   Building vector operands of 0x5f0db48 from scalars instead
...
t.c:18:10: note:   removing SLP instance operations starting from: _25 = _24 +
_40;
t.c:18:10: missed:  not vectorized: bad operation in basic block.
t.c:18:10: note: ***** Analysis failed with vector mode V8QI
t.c:18:10: note: ***** Re-trying analysis with vector mode V4QI

and the ICE is gone.

I'm not sure if we can "recover" in this way or whether leaving
partition.layout unchanged could lead to wrong-code if it were actually
possible to code generate it, thus whether it's really the inability
to generate the permute that triggers this issue.

Related to PR110935, with -Ofast we should elide the unsupported permute.

  parent reply	other threads:[~2024-01-10  8:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 18:51 [Bug middle-end/113205] New: [14 Regression] internal compiler error: in backward_pass, at tree-vect-slp.cc:5346 doko at gcc dot gnu.org
2024-01-02 20:14 ` [Bug middle-end/113205] " doko at gcc dot gnu.org
2024-01-05 14:03 ` jakub at gcc dot gnu.org
2024-01-08 14:41 ` rguenth at gcc dot gnu.org
2024-01-08 17:17 ` [Bug middle-end/113205] [14 Regression] internal compiler error: in backward_pass, at tree-vect-slp.cc:5346 since r14-3220 jakub at gcc dot gnu.org
2024-01-08 17:18 ` jakub at gcc dot gnu.org
2024-01-10  8:12 ` rguenth at gcc dot gnu.org [this message]
2024-02-05 23:59 ` sergio at serjux dot com
2024-02-07 22:16 ` sergio at serjux dot com
2024-02-07 22:19 ` jakub at gcc dot gnu.org
2024-02-07 22:19 ` pinskia at gcc dot gnu.org
2024-02-09  1:18 ` sergio at serjux dot com
2024-02-09  7:24 ` rguenth at gcc dot gnu.org
2024-02-15 14:15 ` jakub at gcc dot gnu.org
2024-02-23 14:47 ` rsandifo at gcc dot gnu.org
2024-02-23 14:48 ` rsandifo at gcc dot gnu.org
2024-02-24 11:58 ` cvs-commit at gcc dot gnu.org
2024-02-24 11:59 ` rsandifo 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-113205-4-5AoQyZWXYF@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).