Bug 103517 - [12 Regression] ICE in as_a, at is-a.h:242 with -O2 -march=skylake-avx512 since r12-5612-g10833849b55401a5
Summary: [12 Regression] ICE in as_a, at is-a.h:242 with -O2 -march=skylake-avx512 sin...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 12.0
: P1 normal
Target Milestone: 12.0
Assignee: Richard Sandiford
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2021-12-01 09:32 UTC by Vsevolod Livinskii
Modified: 2021-12-01 14:39 UTC (History)
5 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-12-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2021-12-01 09:32:57 UTC
The same error exists for Sapphire Rapids

Reproducer:
int a;
short b, c;
extern short d[];
void e() {
  for (short f = 1; f < (short)a; f += 2)
    if (d[f + 1]) {
      b = d[f];
      c = d[f + 1];
    }
}

Error:
>$ g++ -O2 -march=skylake-avx512 -c func.cpp
during GIMPLE pass: vect
func.cpp: In function 'void e()':
func.cpp:4:6: internal compiler error: in as_a, at is-a.h:242
    4 | void e() {
      |      ^
0x8bc06a gphi const* as_a<gphi const*, gimple const>(gimple const*)
	/testing/gcc/gcc_src_master/gcc/is-a.h:242
0x8bc684 gcall* as_a<gcall*, gimple>(gimple*)
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:991
0x8bc684 vect_build_slp_tree_1
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1155
0x14880cc vect_build_slp_tree_2
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1711
0x1487a0c vect_build_slp_tree
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1544
0x1488884 vect_build_slp_tree_2
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:2206
0x1487a0c vect_build_slp_tree
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1544
0x148c230 vect_build_slp_instance
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3019
0x148d6b5 vect_analyze_slp_instance
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3339
0x14920d4 vect_analyze_slp(vec_info*, unsigned int)
	/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3422
0x146d24a vect_analyze_loop_2
	/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:2331
0x146eef9 vect_analyze_loop_1
	/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:2830
0x146f40a vect_analyze_loop(loop*, vec_info_shared*)
	/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:2952
0x14a3359 try_vectorize_loop_1
	/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1047
0x14a3359 try_vectorize_loop
	/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1162
0x14a3fb4 execute
	/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1278

gcc version 12.0.0 20211130 (6b8ecbc6d6652d061d7c72c64352d51eca2df6ca) (GCC)
Comment 1 Martin Liška 2021-12-01 09:36:46 UTC
Thanks for the report, started with 12-5612-g10833849b55401a5.
Comment 2 Richard Sandiford 2021-12-01 10:31:59 UTC
Mine.
Comment 3 GCC Commits 2021-12-01 14:36:52 UTC
The master branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

https://gcc.gnu.org/g:1e625a44f6f3001cea31e0f7c563943ecba92b68

commit r12-5689-g1e625a44f6f3001cea31e0f7c563943ecba92b68
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Wed Dec 1 14:36:24 2021 +0000

    vect: Tighten check for SLP memory groups [PR103517]
    
    When checking for compatible stmts, vect_build_slp_tree_1 did:
    
                   && !(STMT_VINFO_GROUPED_ACCESS (stmt_info)
                        && (first_stmt_code == ARRAY_REF
                            || first_stmt_code == BIT_FIELD_REF
                            || first_stmt_code == INDIRECT_REF
                            || first_stmt_code == COMPONENT_REF
                            || first_stmt_code == MEM_REF)))
    
    That is, it allowed any rhs_code as long as the first_stmt_code
    looked valid.  This had the effect of allowing IFN_MASK_LOAD
    to be paired with an earlier non-call code (but didn't allow
    the reverse).
    
    This patch makes the check symmetrical.
    
    gcc/
            PR tree-optimization/103517
            * tree-vect-slp.c (vect_build_slp_tree_1): When allowing two
            different component references, check the codes of both them,
            rather than just the first.
    
    gcc/testsuite/
            PR tree-optimization/103517
            * gcc.dg/vect/pr103517.c: New test.
Comment 4 Richard Sandiford 2021-12-01 14:39:25 UTC
Fixed.