From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 95F703858C78; Wed, 7 Feb 2024 08:04:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95F703858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707293070; bh=4jXoZOkDZ5Xj1mT3Uvyd0XCT9sSboUW/CQ5FL8nTcUc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m4GW4z78oNJCrm21jWJJwbMY/XU+rMomY90uba5bJ4qJlDL4XM6Iv8bXYRUU1LZ5I mpqpBY/aFyihFdf557bhIAMfVRP77AD1nliz/sX+lm216JElhnYrq3Ad544LCl5ZqP mk8kPF7j5QO/KhnPOeAYyEFevsa16/aaU/Za2Tqg= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113583] Main loop in 519.lbm not vectorized. Date: Wed, 07 Feb 2024 08:04:29 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenther at suse dot de 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113583 --- Comment #14 from rguenther at suse dot de --- On Wed, 7 Feb 2024, juzhe.zhong at rivai dot ai wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113583 >=20 > --- Comment #13 from JuzheZhong --- > Ok. I found the optimized tree: >=20 >=20 > _5 =3D 3.33333333333333314829616256247390992939472198486328125e-1 - _4; > _8 =3D .FMA (_5, 1.229999999999999982236431605997495353221893310546875e= -1, _4); >=20 > Let CST0 =3D 3.33333333333333314829616256247390992939472198486328125e-1, > CST1 =3D 1.229999999999999982236431605997495353221893310546875e-1 >=20 > The expression is equivalent to the following: >=20 > _5 =3D CST0 - _4; > _8 =3D _5 * CST1 + 4; >=20 > That is: >=20 > _8 =3D (CST0 - _4) * CST1 + 4; >=20 > So, We should be able to re-associate it like Clang: >=20 > _8 =3D CST0 * CST1 - _4 * CST1 + 4; ---> _8 =3D CST0 * CST1 + _4 * (1 - C= ST1); >=20 > Since both CST0 * CST1 and 1 - CST1 can be pre-computed during compilation > time. >=20 > Let say CST2 =3D CST0 * CST1, CST3 =3D 1 - CST1, then we can re-associate= as Clang: >=20 > _8 =3D FMA (_4, CST3, CST2). >=20 > Any suggestions for this re-association ? Is match.pd the right place to= do it > ? You need to look at the IL before we do .FMA forming, specifically=20 before/after the late reassoc pass. There pass applying match.pd patterns everywhere is forwprop. I also wonder which compilation flags you are using (note clang has different defaults for example for -ftrapping-math)=