public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
@ 2024-01-24  2:13 mpolacek at gcc dot gnu.org
  2024-01-24  2:39 ` [Bug target/113572] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-24  2:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113572
           Summary: aarch64: internal compiler error in
                    aarch64_sve::vector_cst_all_same
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

typedef unsigned long uint64_t;
#pragma GCC aarch64 "arm_sve.h"

uint64_t u;
struct S { int i; } he;

void
foo ()
{
  svuint64_t vld_clz = svld1_u64 (svwhilelt_b64 (0, 4), (uint64_t *) &he);
  vld_clz = svclz_u64_z (svwhilelt_b64 (0, 1), vld_clz);
  svst1_u64 (svwhilelt_b64 (0, 1), &u, vld_clz);
}

$ ./cc1 -quiet -Iinclude pr.c -O -march=armv8.2-a+sve
during GIMPLE pass: ccp
pr.c: In function ‘foo’:
pr.c:13:1: internal compiler error: Segmentation fault
   13 | }
      | ^
0x10534af crash_signal
        /home/mpolacek/src/gcc/gcc/toplev.cc:317
0x7f997160899f ???
       
/usr/src/debug/glibc-2.38-14.fc39.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xc58d3a location_wrapper_p(tree_node const*)
        /home/mpolacek/src/gcc/gcc/tree.h:4379
0xc58d3a tree_strip_any_location_wrapper(tree_node*)
        /home/mpolacek/src/gcc/gcc/tree.h:4391
0xc58d3a operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
        /home/mpolacek/src/gcc/gcc/fold-const.cc:3122
0xc5be00 operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
        /home/mpolacek/src/gcc/gcc/fold-const.cc:4183
0xc5be00 operand_compare::verify_hash_value(tree_node const*, tree_node const*,
unsigned int, bool*)
        /home/mpolacek/src/gcc/gcc/fold-const.cc:4163
0xc5be00 operand_compare::verify_hash_value(tree_node const*, tree_node const*,
unsigned int, bool*)
        /home/mpolacek/src/gcc/gcc/fold-const.cc:4155
0xc5c807 operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
        /home/mpolacek/src/gcc/gcc/fold-const.cc:3119
0xc5c807 operand_equal_p(tree_node const*, tree_node const*, unsigned int)
        /home/mpolacek/src/gcc/gcc/fold-const.cc:4194
0x1505f77 aarch64_sve::vector_cst_all_same(tree_node*, unsigned int)
        /home/mpolacek/src/gcc/gcc/config/aarch64/aarch64-sve-builtins.cc:3477
0x150b92f aarch64_sve::gimple_folder::redirect_pred_x()
        /home/mpolacek/src/gcc/gcc/config/aarch64/aarch64-sve-builtins.cc:3591
0x150b9ab aarch64_sve::gimple_folder::fold()
        /home/mpolacek/src/gcc/gcc/config/aarch64/aarch64-sve-builtins.cc:3672
0x150ba81 aarch64_sve::gimple_fold_builtin(unsigned int, gimple_stmt_iterator*,
gcall*)
        /home/mpolacek/src/gcc/gcc/config/aarch64/aarch64-sve-builtins.cc:4743
0x141baf2 aarch64_gimple_fold_builtin
        /home/mpolacek/src/gcc/gcc/config/aarch64/aarch64.cc:15499
0xce1490 gimple_fold_call
        /home/mpolacek/src/gcc/gcc/gimple-fold.cc:5669
0xce350b fold_stmt_1
        /home/mpolacek/src/gcc/gcc/gimple-fold.cc:6431
0x12393be substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
        /home/mpolacek/src/gcc/gcc/tree-ssa-propagate.cc:859
0x1dcddee dom_walker::walk(basic_block_def*)
        /home/mpolacek/src/gcc/gcc/domwalk.cc:311
0x1238495 substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
        /home/mpolacek/src/gcc/gcc/tree-ssa-propagate.cc:999

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
@ 2024-01-24  2:39 ` pinskia at gcc dot gnu.org
  2024-01-24  2:51 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-24  2:39 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
           Keywords|needs-bisection             |ice-on-valid-code
   Target Milestone|---                         |14.0
            Summary|aarch64: internal compiler  |[14 Regression] aarch64:
                   |error in                    |internal compiler error in
                   |aarch64_sve::vector_cst_all |aarch64_sve::vector_cst_all
                   |_same                       |_same

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Definitely r14-5881-ge09007308c96a0 as that introduced redirect_pred_x.

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
  2024-01-24  2:39 ` [Bug target/113572] [14 Regression] " pinskia at gcc dot gnu.org
@ 2024-01-24  2:51 ` mpolacek at gcc dot gnu.org
  2024-01-24  2:59 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-24  2:51 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Priority|P3                          |P1
   Last reconfirmed|                            |2024-01-24

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
  2024-01-24  2:39 ` [Bug target/113572] [14 Regression] " pinskia at gcc dot gnu.org
  2024-01-24  2:51 ` mpolacek at gcc dot gnu.org
@ 2024-01-24  2:59 ` pinskia at gcc dot gnu.org
  2024-01-24  6:49 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-24  2:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#6  0x00000000015646e1 in aarch64_sve::vector_cst_all_same (v=0x7ffff6be4d20,
step=8) at ../../gcc/config/aarch64/aarch64-sve-builtins.cc:3477
3477        if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (v, i), first_el, 0))
(gdb) p v
$1 = (tree) 0x7ffff6be4d20
(gdb) p debug_tree(v)
 <vector_cst 0x7ffff6be4d20
    type <vector_type 0x7ffff72f5bd0 __SVBool_t
        type <boolean_type 0x7ffff72f5d20 public QI
            size <integer_cst 0x7ffff741e048 constant 8>
            unit-size <integer_cst 0x7ffff741e060 constant 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff72f5d20 precision:1 min <integer_cst 0x7ffff756b6c0 -1> max <integer_cst
0x7ffff756b8d0 0>>
        VNx16BI
        size <poly_int_cst 0x7ffff72d9e80 type <integer_type 0x7ffff741c0a8
bitsizetype>
            constant
            elt0: <integer_cst 0x7ffff741e108 constant 16> elt1: <integer_cst
0x7ffff741e108 16>>
        unit-size <poly_int_cst 0x7ffff72d9e40 type <integer_type
0x7ffff741c000 sizetype>
            constant
            elt0: <integer_cst 0x7ffff741e120 constant 2> elt1: <integer_cst
0x7ffff741e120 2>>
        align:16 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality
        attributes <tree_list 0x7ffff72fa5f0
            purpose <identifier_node 0x7ffff72f9b40 SVE type>
            value <tree_list 0x7ffff72fa5c8
                value <integer_cst 0x7ffff7402f78 constant 0>
                chain <tree_list 0x7ffff72fa5a0 value <integer_cst
0x7ffff741e060 1>
                    chain <tree_list 0x7ffff72fa578
                        value <identifier_node 0x7ffff72f9aa0 u10__SVBool_t>
                        chain <tree_list 0x7ffff72fa550 value <identifier_node
0x7ffff72f9af0 svbool_t>>>>>
            chain <tree_list 0x7ffff72fa528
                purpose <identifier_node 0x7ffff72f9a50 SVE sizeless type>>>
nunits:[16,16]>
    constant npatterns:1 nelts-per-pattern:2
    elt:0:  <integer_cst 0x7ffff756b6c0 type <boolean_type 0x7ffff72f5d20>
constant -1>
    elt:1:  <integer_cst 0x7ffff756b8d0 type <boolean_type 0x7ffff72f5d20>
constant 0>>
$2 = void
(gdb) p i
$3 = 8

(gdb) p debug_generic_expr(v)
{ -1, 0, ... }


I don't understand what this constant even means. Is it `-1,0` alternating or
is it `-1, 0,` followed by many 0s?

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-01-24  2:59 ` pinskia at gcc dot gnu.org
@ 2024-01-24  6:49 ` jakub at gcc dot gnu.org
  2024-01-24 20:04 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-24  6:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Given the vector-builder.h comment, I believe { -1, 0, ... } with npatterns 1
and nelts-per-pattern 2 means { -1, 0, 0, 0, 0, 0, 0, ... }
/* This class is a wrapper around auto_vec<T> for building vectors of T.
   It aims to encode each vector as npatterns interleaved patterns,
   where each pattern represents a sequence:

     { BASE0, BASE1, BASE1 + STEP, BASE1 + STEP*2, BASE1 + STEP*3, ... }

   The first three elements in each pattern provide enough information
   to derive the other elements.  If all patterns have a STEP of zero,
   we only need to encode the first two elements in each pattern.
   If BASE1 is also equal to BASE0 for all patterns, we only need to
   encode the first element in each pattern.  The number of encoded
   elements per pattern is given by nelts_per_pattern.
Because this is just one pattern (so not interleaved) and doesn't have STEP (so
STEP is zero) and has 2 elements (so BASE0 and BASE1, rather than just BASE0 ==
BASE1).

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-01-24  6:49 ` jakub at gcc dot gnu.org
@ 2024-01-24 20:04 ` jakub at gcc dot gnu.org
  2024-01-24 20:36 ` rsandifo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-24 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
vect_all_same before r14-5880-g31e9074977bb7de83fa5d28d286323987d5d87f2
wouldn't ICE on this, that did
    int nelts = vector_cst_encoded_nelts (v);
    tree first_el = VECTOR_CST_ENCODED_ELT (v, 0);

    for (i = 0; i < nelts; i += step)
      if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (v, i), first_el, 0))
        return false;
and so i was never higher than vector_cst_encoded_nelts,
but the current generalized vector_cst_all_same doesn't guarantee that:
  unsigned int lcm = least_common_multiple (step, VECTOR_CST_NPATTERNS (v));
  unsigned int nelts = lcm * VECTOR_CST_NELTS_PER_PATTERN (v);
  tree first_el = VECTOR_CST_ENCODED_ELT (v, 0);
  for (unsigned int i = 0; i < nelts; i += step)
    if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (v, i), first_el, 0))
      return false;
because least_common_multiple of something and VECTOR_CST_NPATTERNS will often
be
higher than VECTOR_CST_NPATTERNS (unless VECTOR_CST_NPATTERNS is a multiple of
step).

So, if that part is right, I think we want to use VECTOR_CST_ELT instead of
VECTOR_CST_ENCODED_ELT, like:
--- gcc/config/aarch64/aarch64-sve-builtins.cc.jj       2024-01-12
13:47:20.815429012 +0100
+++ gcc/config/aarch64/aarch64-sve-builtins.cc  2024-01-24 20:58:33.720677634
+0100
@@ -3474,7 +3474,7 @@ vector_cst_all_same (tree v, unsigned in
   unsigned int nelts = lcm * VECTOR_CST_NELTS_PER_PATTERN (v);
   tree first_el = VECTOR_CST_ENCODED_ELT (v, 0);
   for (unsigned int i = 0; i < nelts; i += step)
-    if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (v, i), first_el, 0))
+    if (!operand_equal_p (VECTOR_CST_ELT (v, i), first_el, 0))
       return false;

   return true;
which fixes the ICE.

On the testcase, VECTOR_CST_NELTS_PER_PATTERN is 2, VECTOR_CST_NPATTERNS is 1
and
step is 8, so lcm is 8 and nelts 16, while the vector has only 2 encoded elts.

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-01-24 20:04 ` jakub at gcc dot gnu.org
@ 2024-01-24 20:36 ` rsandifo at gcc dot gnu.org
  2024-01-25 12:03 ` cvs-commit at gcc dot gnu.org
  2024-01-25 12:10 ` rsandifo at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-01-24 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rsandifo at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #5 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> So, if that part is right, I think we want to use VECTOR_CST_ELT instead of
> VECTOR_CST_ENCODED_ELT, like:
> --- gcc/config/aarch64/aarch64-sve-builtins.cc.jj	2024-01-12
> 13:47:20.815429012 +0100
> +++ gcc/config/aarch64/aarch64-sve-builtins.cc	2024-01-24 20:58:33.720677634
> +0100
> @@ -3474,7 +3474,7 @@ vector_cst_all_same (tree v, unsigned in
>    unsigned int nelts = lcm * VECTOR_CST_NELTS_PER_PATTERN (v);
>    tree first_el = VECTOR_CST_ENCODED_ELT (v, 0);
>    for (unsigned int i = 0; i < nelts; i += step)
> -    if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (v, i), first_el, 0))
> +    if (!operand_equal_p (VECTOR_CST_ELT (v, i), first_el, 0))
>        return false;
>  
>    return true;
> which fixes the ICE.
Yeah, that's the correct fix.  Sorry for missing it.

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-01-24 20:36 ` rsandifo at gcc dot gnu.org
@ 2024-01-25 12:03 ` cvs-commit at gcc dot gnu.org
  2024-01-25 12:10 ` rsandifo at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-25 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

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

commit r14-8422-gc3de14ba1ba0e77254118af64ed881f115ee42a0
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Thu Jan 25 12:03:18 2024 +0000

    aarch64: Fix out-of-bounds ENCODED_ELT access [PR113572]

    When generalising vector_cst_all_same, I'd forgotten to update
    VECTOR_CST_ENCODED_ELT to VECTOR_CST_ELT.  The check deliberately
    looks at implicitly encoded elements in some cases.

    gcc/
            PR target/113572
            * config/aarch64/aarch64-sve-builtins.cc (vector_cst_all_same):
            Check VECTOR_CST_ELT instead of VECTOR_CST_ENCODED_ELT

    gcc/testsuite/
            PR target/113572
            * gcc.target/aarch64/sve/pr113572.c: New test.

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

* [Bug target/113572] [14 Regression] aarch64: internal compiler error in aarch64_sve::vector_cst_all_same
  2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-01-25 12:03 ` cvs-commit at gcc dot gnu.org
@ 2024-01-25 12:10 ` rsandifo at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-01-25 12:10 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

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

--- Comment #7 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2024-01-25 12:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24  2:13 [Bug target/113572] New: aarch64: internal compiler error in aarch64_sve::vector_cst_all_same mpolacek at gcc dot gnu.org
2024-01-24  2:39 ` [Bug target/113572] [14 Regression] " pinskia at gcc dot gnu.org
2024-01-24  2:51 ` mpolacek at gcc dot gnu.org
2024-01-24  2:59 ` pinskia at gcc dot gnu.org
2024-01-24  6:49 ` jakub at gcc dot gnu.org
2024-01-24 20:04 ` jakub at gcc dot gnu.org
2024-01-24 20:36 ` rsandifo at gcc dot gnu.org
2024-01-25 12:03 ` cvs-commit at gcc dot gnu.org
2024-01-25 12:10 ` rsandifo at gcc dot gnu.org

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