Bug 97079 - [11 Regression] aarch64, SVE: ICE in SLP recognizer since r11-3148-g8d3767c30240c901a493d82d9d20f306b2f0152d
Summary: [11 Regression] aarch64, SVE: ICE in SLP recognizer since r11-3148-g8d3767c30...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P1 normal
Target Milestone: 11.0
Assignee: Martin Liška
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: patch
Depends on:
Blocks:
 
Reported: 2020-09-16 21:37 UTC by Alex Coplan
Modified: 2020-10-12 13:24 UTC (History)
1 user (show)

See Also:
Host:
Target: aarch64
Build:
Known to work:
Known to fail: 11.0
Last reconfirmed: 2020-10-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Coplan 2020-09-16 21:37:31 UTC
Since r11-3148-g8d3767c30240c901a493d82d9d20f306b2f0152d, AArch64 GCC ICEs with -O2 -ftree-vectorize -march=armv8.2-a+sve on the following input:

void g(void);

int a[8][3];
int b;
void c(void) {
  int d[] = {7, 3};
  int *e = a[0];
  int f;
  b = 0;
  for (; b < 8; b++) {
    f = 0;
    for (; f < 3; f++)
      a[b][f] = 0;
  }
  g();
  *e = (long)d;
}

To reproduce:

$ aarch64-none-elf-gcc -c -march=armv8.2-a+sve -O2 -ftree-vectorize test.c
during GIMPLE pass: slp
test.c: In function 'c':
test.c:5:6: internal compiler error: Segmentation fault
    5 | void c(void) {
      |      ^
0xd628ff crash_signal
        /home/alecop01/toolchain/src/gcc/gcc/toplev.c:327
0x1a012ad contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
        /home/alecop01/toolchain/src/gcc/gcc/tree.h:3408
0x1a012ad vect_recog_mask_conversion_pattern
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:4262
0x19faf66 vect_pattern_recog_1
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:5339
0x1a0351f vect_pattern_recog(vec_info*)
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:5495
0x10a010e vect_slp_analyze_bb_1
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3545
0x10a010e vect_slp_region
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3648
0x10a010e vect_slp_bb(basic_block_def*)
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3804
0x10a4888 execute
        /home/alecop01/toolchain/src/gcc/gcc/tree-vectorizer.c:1433
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Richard Biener 2020-09-17 06:36:05 UTC
Probably a bad bisection - the commit just restores cost modeling.
Comment 2 Alex Coplan 2020-09-17 08:28:03 UTC
Ah, yes, the ICE re-appears immediately prior to r11-3095-g47ddf4c7b1d4471cb9534f27844ab5e4279c2168, so the bug was temporarily hidden on trunk.

I'll do another bisect, thanks.
Comment 3 Alex Coplan 2020-09-17 09:53:40 UTC
It seems this was introduced with r11-2817-gcdb2e365fc0dba2ee052827e5ca65234ca82d605:

commit cdb2e365fc0dba2ee052827e5ca65234ca82d605
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Jul 31 09:53:39 2020

    SLP: support entire BB.
Comment 4 Alex Coplan 2020-10-09 14:36:39 UTC
Related testcase that gives a similar ICE:

int c, d;
int e[1];
void a(int *);
void f(void) {
  while (d);
  int g[5];
  for (; d < 2; d++)
    e[d] = c;
  for (; d; d++)
    g[d] = (long)e;
  a(g);
}

$ aarch64-elf-gcc -c test.c -O1 -ftree-vectorize -march=armv8.2-a+sve
during GIMPLE pass: slp
test.c: In function 'f':
test.c:4:6: internal compiler error: Segmentation fault
    4 | void f(void) {
      |      ^
0xd89397 crash_signal
        /home/alecop01/toolchain/src/gcc/gcc/toplev.c:330
0x1a408b7 contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
        /home/alecop01/toolchain/src/gcc/gcc/tree.h:3416
0x1a408b7 vect_convert_input
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:728
0x1a411f6 vect_convert_inputs
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:818
0x1a418bb vect_recog_over_widening_pattern
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:1718
0x1a3ba60 vect_pattern_recog_1
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:5344
0x1a44001 vect_pattern_recog(vec_info*)
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-patterns.c:5502
0x10c994e vect_slp_analyze_bb_1
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3564
0x10c994e vect_slp_region
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3663
0x10c994e vect_slp_bbs
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3819
0x10cb0d1 vect_slp_function(function*)
        /home/alecop01/toolchain/src/gcc/gcc/tree-vect-slp.c:3870
0x10ce3d9 execute
        /home/alecop01/toolchain/src/gcc/gcc/tree-vectorizer.c:1432
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

We don't ICE at -O2 and above here.
Comment 5 Martin Liška 2020-10-12 06:59:54 UTC
Mine then.
Comment 6 Martin Liška 2020-10-12 10:32:20 UTC
(In reply to Alex Coplan from comment #3)
> It seems this was introduced with
> r11-2817-gcdb2e365fc0dba2ee052827e5ca65234ca82d605:
> 
> commit cdb2e365fc0dba2ee052827e5ca65234ca82d605
> Author: Martin Liska <mliska@suse.cz>
> Date:   Fri Jul 31 09:53:39 2020
> 
>     SLP: support entire BB.

This revision can be fixed with:

diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 92cb3cd845a..792d2ca568a 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -3795,6 +3795,7 @@ internal_fn_stored_value_index (internal_fn fn)
   switch (fn)
     {
     case IFN_MASK_STORE:
+    case IFN_MASK_STORE_LANES:
     case IFN_SCATTER_STORE:
     case IFN_MASK_SCATTER_STORE:
     case IFN_LEN_STORE:

But it does not help for master, I'm investigating right now..
Comment 7 Martin Liška 2020-10-12 10:42:38 UTC
All right, I think I have a proper fix.
Comment 8 GCC Commits 2020-10-12 13:23:36 UTC
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

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

commit r11-3821-gbd28b730cf35dbeeb2b26aa17397163bbbb0ca9e
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Oct 12 12:54:31 2020 +0200

    SLP: fix SVE issues
    
    The patch fixes the following 2 issues:
    
      .MASK_STORE_LANES (&a, 4B, max_mask_34, vect_array.12);
    
    here we miss to return the last argument as stored value.
    
    ivtmp_32 = ivtmp_31 + POLY_INT_CST [4, 4];
    
    here we miss a bail out in vect_recog_over_widening_pattern.
    
    gcc/ChangeLog:
    
            PR tree-optimization/97079
            * internal-fn.c (internal_fn_stored_value_index): Handle also
            .MASK_STORE_LANES.
            * tree-vect-patterns.c (vect_recog_over_widening_pattern): Bail
            out for unsupported TREE_TYPE.
    
    gcc/testsuite/ChangeLog:
    
            PR tree-optimization/97079
            * gcc.target/aarch64/sve/pr97079.c: New test.
Comment 9 Martin Liška 2020-10-12 13:24:02 UTC
Fixed.