From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3F55E3858C53; Wed, 7 Feb 2024 07:48:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F55E3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707292110; bh=L62PylF5HYNNBr8beMJcnFtE1HdfP3X9BLJLfeVagqM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=C8jF+SlAS85IIWrQhmRB1fRK3+I34dwY8Z4mlgHvI/4kEBHbPTBxzrHqSBVju7Zfx zlcaqi9MZHGKK+lyXKYUZRc9FhXVdMwl7uYk6ATYgznOO07SdV7U3Do6DxybdO/aYw Nxcdr3FmvbH6gTAd1GFLVxaB6TOB7mm31Az2ZCGU= From: "juzhe.zhong at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113583] Main loop in 519.lbm not vectorized. Date: Wed, 07 Feb 2024 07:48: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: juzhe.zhong at rivai dot ai 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 #13 from JuzheZhong --- Ok. I found the optimized tree: _5 =3D 3.33333333333333314829616256247390992939472198486328125e-1 - _4; _8 =3D .FMA (_5, 1.229999999999999982236431605997495353221893310546875e-1= , _4); Let CST0 =3D 3.33333333333333314829616256247390992939472198486328125e-1, CST1 =3D 1.229999999999999982236431605997495353221893310546875e-1 The expression is equivalent to the following: _5 =3D CST0 - _4; _8 =3D _5 * CST1 + 4; That is: _8 =3D (CST0 - _4) * CST1 + 4; So, We should be able to re-associate it like Clang: _8 =3D CST0 * CST1 - _4 * CST1 + 4; ---> _8 =3D CST0 * CST1 + _4 * (1 - CST= 1); Since both CST0 * CST1 and 1 - CST1 can be pre-computed during compilation time. Let say CST2 =3D CST0 * CST1, CST3 =3D 1 - CST1, then we can re-associate a= s Clang: _8 =3D FMA (_4, CST3, CST2). Any suggestions for this re-association ? Is match.pd the right place to d= o it ? Thanks.=