From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63FA5388F066; Mon, 29 Jun 2020 12:12:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63FA5388F066 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593432743; bh=/gQI6A2XZahUU7W3dgzBPB/wc7oGKPHBVHjM0HQMJhE=; h=From:To:Subject:Date:From; b=GdV1VXg3z16XXj0aYsRG7fuNfypxXOrRSO9JikQQjRmq+unBVhJ+IVGpy1LxR0Wc8 yrH3IgayahmTeqsJxSLKaCq4DQ+JBCJ9RB6PlyIiJomxgH7TSdNOC7J2fiHbmkuqeY pdsDhr+ryJBaAyl4sr/P1B07vKP+A2PLPo1dJQ0w= From: "felix.yang at huawei dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95961] New: ICE: in exact_div, at poly-int.h:2182 Date: Mon, 29 Jun 2020 12:12:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: felix.yang at huawei dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2020 12:12:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95961 Bug ID: 95961 Summary: ICE: in exact_div, at poly-int.h:2182 Product: gcc Version: 11.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 test case: $ cat foo.c typedef struct { unsigned short mprr_2[5][16][16]; } ImageParameters; int s[16][2]; void intrapred_luma_16x16(ImageParameters *img, int s0) { for (int j =3D 0; j < 16; j++) for (int i =3D 0; i < 16; i++) { img->mprr_2[1][j][i] =3D s[j][1]; img->mprr_2[2][j][i] =3D s0; } } Command line to reproduce: $ gcc -O3 -march=3Darmv8.2-a+sve -fno-vect-cost-model foo.c Call trace: during GIMPLE pass: vect dump file: a-foo.c.163t.vect foo.c: In function =E2=80=98intrapred_luma_16x16=E2=80=99: foo.c:7:6: internal compiler error: in exact_div, at poly-int.h:2182 7 | void intrapred_luma_16x16(ImageParameters *img, int s0) | ^~~~~~~~~~~~~~~~~~~~ v0xdb6937 poly_int<2u, poly_result::result_kind>::type> exact_div<2u, unsigned long, unsigned long>(poly_int_pod<2u, unsigned long> const&, poly_int_pod<2u, unsigned long> const&) ../../gcc-git/gcc/poly-int.h:2182 0x22934ef vect_get_num_vectors ../../gcc-git/gcc/tree-vectorizer.h:1647 0x2297d5f vect_enhance_data_refs_alignment(_loop_vec_info*) ../../gcc-git/gcc/tree-vect-data-refs.c:1827 0x1686adf vect_analyze_loop_2 ../../gcc-git/gcc/tree-vect-loop.c:2138 0x1688267 vect_analyze_loop(loop*, vec_info_shared*) ../../gcc-git/gcc/tree-vect-loop.c:2612 0x16c77e7 try_vectorize_loop_1 ../../gcc-git/gcc/tree-vectorizer.c:955 0x16c7f6f try_vectorize_loop ../../gcc-git/gcc/tree-vectorizer.c:1110 0x16c811f vectorize_loops() ../../gcc-git/gcc/tree-vectorizer.c:1189 0x151e6df execute ../../gcc-git/gcc/tree-ssa-loop.c:414 In vect_enhance_data_refs_alignment, when we call vect_get_num_vectors, we have: (gdb) p nscalars $11 =3D {> =3D {coeffs =3D {2, 2}}, } (gdb) p debug_tree(vectype) unit-size align:32 warn_if_not_align:0 symtab:0 alias-set 1 canonical-type 0xffffb22305e8 precision:32 min max pointer_to_this > VNx4SI ...... (gdb) p TYPE_VECTOR_SUBPARTS (vectype) $13 =3D {> =3D {coeffs =3D {4, 4}}, } nscalars is not a multiple of number of elements of vectype, which triggers= the ICE. In the vect pass, vectorization factor computed by vect_determine_vectorization_factor is [8,8]. But this is updated to [1, 1] later by vect_update_vf_for_slp, as indicated in the phase dump: 7860 foo.c:9:3: note: =3D=3D=3D vect_make_slp_decision =3D=3D=3D 7861 foo.c:9:3: note: Decided to SLP 2 instances. Unrolling factor [1,1] 7862 foo.c:9:3: note: =3D=3D=3D vect_detect_hybrid_slp =3D=3D=3D 7863 foo.c:9:3: note: =3D=3D=3D vect_update_vf_for_slp =3D=3D=3D 7864 foo.c:9:3: note: Loop contains only SLP stmts 7865 foo.c:9:3: note: Updating vectorization factor to [1,1]. 7866 foo.c:9:3: note: vectorization_factor =3D [1,1], niters =3D 16 This logic here was once changed by commit d9f21f6acb3aa615834e855e16b6311cd18c5668: 323 if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo))) 324 { 325 - if (STMT_SLP_TYPE (stmt_info)) 326 - possible_npeel_number 327 - =3D (vf * GROUP_SIZE (stmt_info)) / nelements; 328 - else 329 - possible_npeel_number =3D vf / nelements; 330 + poly_uint64 nscalars =3D (STMT_SLP_TYPE (stmt_info) 331 + ? vf * GROUP_SIZE (stmt_info= ) : vf); 332 + possible_npeel_number 333 + =3D vect_get_num_vectors (nscalars, vectype); Proposed fix: diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index eb8288e7a85..b30a7d8a3bb 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -1823,8 +1823,11 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) { poly_uint64 nscalars =3D (STMT_SLP_TYPE (stmt_info) ? vf * DR_GROUP_SIZE (stmt_info) : vf); - possible_npeel_number - =3D vect_get_num_vectors (nscalars, vectype); + if (maybe_lt (nscalars, TYPE_VECTOR_SUBPARTS (vectype))) + possible_npeel_number =3D 0; + else + possible_npeel_number + =3D vect_get_num_vectors (nscalars, vectype); /* NPEEL_TMP is 0 when there is no misalignment, but also allow peeling NELEMENTS. */=