From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0635E3893674; Fri, 18 Dec 2020 01:13:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0635E3893674 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98365] New: Miss vectoization Date: Fri, 18 Dec 2020 01:13:28 +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: crazylht at gmail 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 cc target_milestone cf_gcchost 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: Fri, 18 Dec 2020 01:13:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98365 Bug ID: 98365 Summary: Miss vectoization Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com CC: hjl.tools at gmail dot com, wwwhhhyyy333 at gmail dot c= om Target Milestone: --- Host: x86_64-pc-linux-gnu cat test.c int foo (char a[64], char c[64]) { int i; char cnt=3D0; for (int i =3D 0;i !=3D 64; i++) if (a[i] =3D=3D c[i]) cnt++; return cnt; } with -Ofast -mavx2 gcc failed to vectorize the loop due to=20 dump of loop body: ----------- # cnt_21 =3D PHI # i_22 =3D PHI # ivtmp_19 =3D PHI _1 =3D (sizetype) i_22; _2 =3D a_14(D) + _1; _3 =3D *_2; _5 =3D c_15(D) + _1; _6 =3D *_5; cnt.1_7 =3D (unsigned char) cnt_21; _8 =3D cnt.1_7 + 1; cnt_16 =3D (char) _8; cnt_9 =3D _3 =3D=3D _6 ? cnt_16 : cnt_21; i_17 =3D i_22 + 1; ivtmp_18 =3D ivtmp_19 - 1; ---------- -fopt-info --------- test.c:5:20: note: vec_stmt_relevant_p: stmt live but not relevant. test.c:5:20: note: mark relevant 1, live 1: cnt_9 =3D _3 =3D=3D _6 ? cnt_= 16 : cnt_21; test.c:5:20: note: init: stmt relevant? i_17 =3D i_22 + 1; test.c:5:20: note: init: stmt relevant? ivtmp_18 =3D ivtmp_19 - 1; test.c:5:20: note: init: stmt relevant? if (ivtmp_18 !=3D 0) test.c:5:20: note: worklist: examine stmt: cnt_9 =3D _3 =3D=3D _6 ? cnt_1= 6 : cnt_21; test.c:5:20: note: vect_is_simple_use: operand *_2, type of def: internal test.c:5:20: note: mark relevant 1, live 0: _3 =3D *_2; test.c:5:20: note: vect_is_simple_use: operand *_5, type of def: internal test.c:5:20: note: mark relevant 1, live 0: _6 =3D *_5; test.c:5:20: note: vect_is_simple_use: operand (char) _8, type of def: internal test.c:5:20: note: mark relevant 1, live 0: cnt_16 =3D (char) _8; test.c:5:20: note: vect_is_simple_use: operand cnt_21 =3D PHI , type of def: unknown test.c:5:20: missed: Unsupported pattern. ---------------- Shouldn't cnt_21 =3D PHI , stmt relevant? BTW: with extra -fwrapv, gcc successfully vectorized the loop.=