From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 36D8E396E866; Tue, 17 Aug 2021 09:47:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36D8E396E866 From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101944] suboptimal SLP for reduced case from namd_r Date: Tue, 17 Aug 2021 09:47:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw at gcc dot gnu.org 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: Message-ID: In-Reply-To: References: 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: Tue, 17 Aug 2021 09:47:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101944 --- Comment #2 from Kewen Lin --- Back to the optimized IR, I thought the problem is that the vectorized version has longer critical path for the reduc_plus result (latency in tota= l). For vectorized version, _51 =3D diffa_41(D) * 1.666666666666666574148081281236954964697360992431640625e-1; _59 =3D {_51, 2.5e-1}; vect__20.13_60 =3D vect_vdw_d_37.12_56 * _59; _61 =3D .REDUC_PLUS (vect__20.13_60); The critical path is: scalar mult -> vect CTOR -> vector mult -> reduc_plus While for the scalar version: _51 =3D diffa_41(D) * 1.666666666666666574148081281236954964697360992431640625e-1; _21 =3D vdw_c_38 * 2.5e-1; _22 =3D .FMA (vdw_d_37, _51, _21); Two scalar mult can run in parallel and it further ends up with one FMA. On Power9, we don't have one unique REDUC_PLUS insn for double, it takes th= ree insns: vector shift + vector addition + vector extraction. I'm not sure if this is a problem on the platforms which support efficient REDUC_PLUS, but = it seems a bad idea to SLP that case where the root is reduc op, its feeders a= re not isomorphic and whose types are V2* and can be math optimized.=