From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D857339DA014; Wed, 21 Apr 2021 05:48:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D857339DA014 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/100173] New: telecom/viterb00data_1 has 16.92% regression compared O2 -ftree-vectorize -fvect-cost-model=very-cheap to O2 on CLX/ICX, 9% regression on znver3 Date: Wed, 21 Apr 2021 05:48:46 +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 cf_gcctarget attachments.created 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: Wed, 21 Apr 2021 05:48:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100173 Bug ID: 100173 Summary: telecom/viterb00data_1 has 16.92% regression compared O2 -ftree-vectorize -fvect-cost-model=3Dvery-cheap to O2 on CLX/ICX, 9% regression on znver3 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 Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-*-* i?86-*-* Created attachment 50647 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50647&action=3Dedit ACS.cpp cat testcase void __attribute__ ((noipa)) ACS(e_s16 *pBranchMetric) { n_int i; e_s16 esMetricIn, esMetric1, esMetric2; StatePathMetricData *pIn1 =3D BufPtr[BufSelector]; StatePathMetricData *pIn2 =3D pIn1 + (1<<5)/2; StatePathMetricData *pOut =3D BufPtr[1 - BufSelector]; BufSelector ^=3D 1; for (i =3D 0; i < (1<<5)/2; i++) { esMetricIn =3D *pBranchMetric++; esMetric1 =3D pIn1->m_esPathMetric - esMetricIn; esMetric2 =3D pIn2->m_esPathMetric + esMetricIn; if (esMetric1 >=3D esMetric2) { pOut->m_esPathMetric =3D esMetric1; pOut->m_esState =3D (pIn1->m_esState << 1); } else { pOut->m_esPathMetric =3D esMetric2; pOut->m_esState =3D (pIn2->m_esState << 1); } pOut++; esMetric1 =3D pIn1->m_esPathMetric + esMetricIn; esMetric2 =3D pIn2->m_esPathMetric - esMetricIn; if (esMetric1 >=3DesMetric2) { pOut->m_esPathMetric =3DesMetric1; pOut->m_esState =3D (pIn1->m_esState << 1) | 1; } else { pOut->m_esPathMetric =3DesMetric2; pOut->m_esState =3D (pIn2->m_esState << 1) | 1; } pOut++; pIn1++; pIn2++; } } It is if conditional store replacement plays here, it sinks 2 stores from I= F_BB and ELSE_BB to JOIN_BB since they have same address. But failed to vectorize them with -fvect-cost-model=3Dvery-cheap, and it causes worse IPC for conse= cutive stores in JOIN_BB on both ICX and znver3. With -fvect-cost-model=3Dcheap, t= he loop can be vectorized and 2.6x faster than O2. So I think we should either vectorize this loop or not sink conditional sto= res when cost model is very-cheap. and the codes related are here:=20 /* If either vectorization or if-conversion is disabled then do not sink any stores. */ if (param_max_stores_to_sink =3D=3D 0 || (!flag_tree_loop_vectorize && !flag_tree_slp_vectorize) || !flag_tree_loop_if_convert) return false;=