public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94784] New: ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482
@ 2020-04-27  7:04 felix.yang at huawei dot com
  2020-04-27  7:09 ` [Bug tree-optimization/94784] " felix.yang at huawei dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: felix.yang at huawei dot com @ 2020-04-27  7:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94784
           Summary: ICE: in simplify_vector_constructor, at
                    tree-ssa-forwprop.c:2482
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix.yang at huawei dot com
  Target Milestone: ---
            Target: aarch64

I see one gcc_assert was introduce in: 
https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544271.html

It looks like this is causing an ICE when compiling the foo.c test.
Gimple input to forwprop4 pass looks like:
pass_v4hi (v4hi v)
{
  vector(4) short int * vectp.4;
  vector(4) short int * vectp_a.3;
  union u4hi u;
  int j;
  short int _2;
  short int _3;
  vector(4) short int _6;
  short int _25;
  short int _26;

  <bb 2> [local count: 214748368]:
  _3 = BIT_FIELD_REF <v_5(D), 16, 0>;
  _2 = BIT_FIELD_REF <v_5(D), 16, 16>;
  _26 = BIT_FIELD_REF <v_5(D), 16, 32>;
  _25 = BIT_FIELD_REF <v_5(D), 16, 48>;
  _6 = {_3, _2, _26, _25};                                                     
 <========
  MEM <vector(4) short int> [(short int *)&a] = _6;  <========
  u ={v} {CLOBBER};
  return;
}

Here at the crash site, we have two vector types with different modes:

(gdb) p debug_tree (src_type)
 <vector_type 0xffffb20f73f0 v4hi
    type <integer_type 0xffffb22ea498 short int sizes-gimplified HI
        size <integer_cst 0xffffb22d0f48 constant 16>
        unit-size <integer_cst 0xffffb22d0f60 constant 2>
        align:16 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type
0xffffb22ea498 precision:16 min <integer_cst 0xffffb22d0f00 -32768> max
<integer_cst 0xffffb22d0f18 32767>
        pointer_to_this <pointer_type 0xffffb240f000>>
    sizes-gimplified V4HI
    size <integer_cst 0xffffb22d0d98 type <integer_type 0xffffb22ea0a8
bitsizetype> constant 64>
    unit-size <integer_cst 0xffffb22d0db0 type <integer_type 0xffffb22ea000
sizetype> constant 8>
    align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0xffffb23b1690 nunits:4 context <translation_unit_decl 0xffffb20f68e8 foo.c>>
$5 = void

(gdb) p debug_tree (type)
 <vector_type 0xffffb20f7348
    type <integer_type 0xffffb22ea498 short int sizes-gimplified HI
        size <integer_cst 0xffffb22d0f48 constant 16>
        unit-size <integer_cst 0xffffb22d0f60 constant 2>
        align:16 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type
0xffffb22ea498 precision:16 min <integer_cst 0xffffb22d0f00 -32768> max
<integer_cst 0xffffb22d0f18 32767>
        pointer_to_this <pointer_type 0xffffb240f000>>
    VNx2HI
    size <integer_cst 0xffffb22d0d98 type <integer_type 0xffffb22ea0a8
bitsizetype> constant 64>
    unit-size <integer_cst 0xffffb22d0db0 type <integer_type 0xffffb22ea000
sizetype> constant 8>
    align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0xffffb23b1690 nunits:4
    pointer_to_this <pointer_type 0xffffb20f77e0>>
$6 = void

foo.c
typedef short __attribute__((vector_size (8))) v4hi; typedef union U4HI { v4hi
v; short a[4]; } u4hi;

short a[4];

void pass_v4hi (v4hi v) {
    int j;
    u4hi u;
    u.v = v;
    for (j = 0; j < 4; j++)
      a[j] = u.a[j];
};

$ aarch64-linux-gnu-gcc -S -O2 -ftree-slp-vectorize -march=armv8.2-a+sve
-msve-vector-bits=256 foo.c during GIMPLE pass: forwprop dump file:
foo.c.190t.forwprop4
foo.c: In function ‘pass_v4hi’:
foo.c:7:6: internal compiler error: in simplify_vector_constructor, at
tree-ssa-forwprop.c:2482
    7 | void pass_v4hi (v4hi v) {
      |      ^~~~~~~~~
0x147dbf7 simplify_vector_constructor
        ../../gcc-git/gcc/tree-ssa-forwprop.c:2482
0x1480a2b execute
        ../../gcc-git/gcc/tree-ssa-forwprop.c:3151

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

* [Bug tree-optimization/94784] ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482
  2020-04-27  7:04 [Bug tree-optimization/94784] New: ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482 felix.yang at huawei dot com
@ 2020-04-27  7:09 ` felix.yang at huawei dot com
  2020-04-27  7:10 ` felix.yang at huawei dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: felix.yang at huawei dot com @ 2020-04-27  7:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Fei Yang <felix.yang at huawei dot com> ---
I did some check and it looks like everything works fine before the ICE.

The reason for the assert is that applying VIEW_CONVERT_EXPR to two general
vectors is dangerous in this context.  If through some bug we ended up with one
vector being V4HI and the other being V2SI (say), the assert stops us from
silently miscompiling the code.

In the testcase we have two vectors with the same ABI identity but with
different TYPE_MODEs. As suggested by Richard Sandiford, it would be better to
flip the assert around so that it checks that the two vectors have equal
TYPE_VECTOR_SUBPARTS and that converting the corresponding element types is a
useless_type_conversion_p.

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

* [Bug tree-optimization/94784] ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482
  2020-04-27  7:04 [Bug tree-optimization/94784] New: ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482 felix.yang at huawei dot com
  2020-04-27  7:09 ` [Bug tree-optimization/94784] " felix.yang at huawei dot com
@ 2020-04-27  7:10 ` felix.yang at huawei dot com
  2020-04-27 10:08 ` cvs-commit at gcc dot gnu.org
  2020-04-27 14:25 ` rsandifo at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: felix.yang at huawei dot com @ 2020-04-27  7:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Fei Yang <felix.yang at huawei dot com> ---
Will propose a patch for review.

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

* [Bug tree-optimization/94784] ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482
  2020-04-27  7:04 [Bug tree-optimization/94784] New: ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482 felix.yang at huawei dot com
  2020-04-27  7:09 ` [Bug tree-optimization/94784] " felix.yang at huawei dot com
  2020-04-27  7:10 ` felix.yang at huawei dot com
@ 2020-04-27 10:08 ` cvs-commit at gcc dot gnu.org
  2020-04-27 14:25 ` rsandifo at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-27 10:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:5328710be314dee43da8027dbff547d48b85e35e

commit r10-7987-g5328710be314dee43da8027dbff547d48b85e35e
Author: Fei Yang <felix.yang@huawei.com>
Date:   Mon Apr 27 11:08:04 2020 +0100

    forwprop: Fix ICE when building an identity constructor [PR94784]

    In the testcase for PR94784, we have two vectors with the same ABI identity
    but with different TYPE_MODEs. It would be better to flip the assert around
    so that it checks that the two vectors have equal TYPE_VECTOR_SUBPARTS and
    that converting the corresponding element types is a
useless_type_conversion_p.

    2020-04-27  Felix Yang  <felix.yang@huawei.com>

    gcc/
            PR tree-optimization/94784
            * tree-ssa-forwprop.c (simplify_vector_constructor): Flip the
            assert around so that it checks that the two vectors have equal
            TYPE_VECTOR_SUBPARTS and that converting the corresponding element
            types is a useless_type_conversion_p.

    gcc/testsuite/
            PR tree-optimization/94784
            * gcc.dg/pr94784.c: New test.

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

* [Bug tree-optimization/94784] ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482
  2020-04-27  7:04 [Bug tree-optimization/94784] New: ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482 felix.yang at huawei dot com
                   ` (2 preceding siblings ...)
  2020-04-27 10:08 ` cvs-commit at gcc dot gnu.org
@ 2020-04-27 14:25 ` rsandifo at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2020-04-27 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Fixed on trunk.

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

end of thread, other threads:[~2020-04-27 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27  7:04 [Bug tree-optimization/94784] New: ICE: in simplify_vector_constructor, at tree-ssa-forwprop.c:2482 felix.yang at huawei dot com
2020-04-27  7:09 ` [Bug tree-optimization/94784] " felix.yang at huawei dot com
2020-04-27  7:10 ` felix.yang at huawei dot com
2020-04-27 10:08 ` cvs-commit at gcc dot gnu.org
2020-04-27 14:25 ` 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).