public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
@ 2022-11-16 15:13 tnfchris at gcc dot gnu.org
  2022-11-16 15:52 ` [Bug tree-optimization/107717] " tnfchris at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2022-11-16 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107717
           Summary: [13 Regression] ICEs expanding permutes after
                    g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tnfchris at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*

After

commit dc95e1e9702f2f6367bbc108c8d01169be1b66d2 (origin/trunk, origin/master,
origin/HEAD)
Author: Hongyu Wang <hongyu.wang@intel.com>
Date:   Mon Jan 17 13:01:51 2022 +0800

    Optimize VEC_PERM_EXPR with same permutation index and operation

    The sequence
         c1 = VEC_PERM_EXPR (a, a, mask)
         c2 = VEC_PERM_EXPR (b, b, mask)
         c3 = c1 op c2
    can be optimized to
         c = a op b
         c3 = VEC_PERM_EXPR (c, c, mask)
    for all integer vector operation, and float operation with
    full permutation.

    gcc/ChangeLog:

            PR target/98167
            * match.pd: New perm + vector op patterns for int and fp vector.

    gcc/testsuite/ChangeLog:

            PR target/98167
            * gcc.target/i386/pr98167.c: New test.

We see various ICEs, an example is

void foo(int n, char *restrict out, char *restrict in) {
  for (int i=n; i-->0; ) {
    out[i] += in[i];
  }
}

compiled with

aarch64-none-linux-gnu -O3 -march=armv8-a+sve2

The problem is that the match.pd pattern as written causes the permute to
switch from a single register permute to a two register one.

The reason is that when the folded result is expanded in SSA form

vec_perm (op @0 @1) (op @0 @1)

the result of applying op twice results in two distinct SSA names. This fails
because expand_vec_perm_const now tries to use a two operand expansion because
there's no easy way to tell that these two operands are the same.

If it happens early enough we can CSE the operands, but when this happens after
vec_lower it generated something the target does not support.

I tried getting expand_vec_perm_const to recognize that they are the same, but
that's quite hard.

It's best to prevent the generation of the two SSA names to begin with, or add
an additional rule for match.pd that's able to CSE this.

I'm making this issue because I don't know which approach upstream would like
so it's easier to ask first.

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

* [Bug tree-optimization/107717] [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
  2022-11-16 15:13 [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2 tnfchris at gcc dot gnu.org
@ 2022-11-16 15:52 ` tnfchris at gcc dot gnu.org
  2022-11-17  8:08 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2022-11-16 15:52 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |tnfchris at gcc dot gnu.org

--- Comment #1 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
testing a patch.

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

* [Bug tree-optimization/107717] [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
  2022-11-16 15:13 [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2 tnfchris at gcc dot gnu.org
  2022-11-16 15:52 ` [Bug tree-optimization/107717] " tnfchris at gcc dot gnu.org
@ 2022-11-17  8:08 ` rguenth at gcc dot gnu.org
  2022-11-17  8:22 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-17  8:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

* [Bug tree-optimization/107717] [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
  2022-11-16 15:13 [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2 tnfchris at gcc dot gnu.org
  2022-11-16 15:52 ` [Bug tree-optimization/107717] " tnfchris at gcc dot gnu.org
  2022-11-17  8:08 ` rguenth at gcc dot gnu.org
@ 2022-11-17  8:22 ` cvs-commit at gcc dot gnu.org
  2022-11-17  8:29 ` tnfchris at gcc dot gnu.org
  2022-11-18  8:24 ` wwwhhhyyy333 at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-17  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <tnfchris@gcc.gnu.org>:

https://gcc.gnu.org/g:cbe313060cdcf1d857d42a9e16a1a03e5ff89fff

commit r13-4123-gcbe313060cdcf1d857d42a9e16a1a03e5ff89fff
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Thu Nov 17 08:20:59 2022 +0000

    middle-end: ensure that VEC_PERM operands get lowered to the same SSA_NAME.
[PR107717]

    At the moment when the VEC_PERMs generated by this match.pd rule is
generated
    it creates two different SSA_NAMEs for the folded operand.  Because of this
it
    the permute switches from a single operand permute to a two operand permute
and
    the target may no longer support a permute for this.

    This fixes it by ensuring we generate the same SSA_NAME for both operands.

    gcc/ChangeLog:

            PR tree-optimization/107717
            * match.pd: Ensure same SSA_NAME.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/107717
            * gcc.target/aarch64/sve2/pr107717.c: New test.

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

* [Bug tree-optimization/107717] [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
  2022-11-16 15:13 [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2 tnfchris at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-11-17  8:22 ` cvs-commit at gcc dot gnu.org
@ 2022-11-17  8:29 ` tnfchris at gcc dot gnu.org
  2022-11-18  8:24 ` wwwhhhyyy333 at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2022-11-17  8:29 UTC (permalink / raw)
  To: gcc-bugs

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

Tamar Christina <tnfchris at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Fixed

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

* [Bug tree-optimization/107717] [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2
  2022-11-16 15:13 [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2 tnfchris at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-11-17  8:29 ` tnfchris at gcc dot gnu.org
@ 2022-11-18  8:24 ` wwwhhhyyy333 at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: wwwhhhyyy333 at gmail dot com @ 2022-11-18  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Hongyu Wang <wwwhhhyyy333 at gmail dot com> ---
(In reply to Tamar Christina from comment #3)
> Fixed

Thanks for the fix! It also give me a good tip for match pattern writing :)

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

end of thread, other threads:[~2022-11-18  8:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 15:13 [Bug tree-optimization/107717] New: [13 Regression] ICEs expanding permutes after g:dc95e1e9702f2f6367bbc108c8d01169be1b66d2 tnfchris at gcc dot gnu.org
2022-11-16 15:52 ` [Bug tree-optimization/107717] " tnfchris at gcc dot gnu.org
2022-11-17  8:08 ` rguenth at gcc dot gnu.org
2022-11-17  8:22 ` cvs-commit at gcc dot gnu.org
2022-11-17  8:29 ` tnfchris at gcc dot gnu.org
2022-11-18  8:24 ` wwwhhhyyy333 at gmail dot com

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