From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F0B90385841C; Sun, 24 Sep 2023 16:33:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0B90385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695573201; bh=1aVx9XVzDSMx3sqShoAppgN4s9iibAX7megSw3cEnu4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ibl1VXGRlcTcvzJ0X0kHBL3Hem+pprBGBn86pRovB9Z3uR7n3tfgCTi/eitwezRDk AsqRi+51pJZLqOjvO1GwDBiDBTPnwU19E7GhWNK4uskLe7dHnsg1+g3H/t4+6tEOhP tjPyr35QFkn5sRTmFmQrF+lPkoRUnMzN4FCxxR44= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111563] Missed optimization of LICM Date: Sun, 24 Sep 2023 16:33:21 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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=3D111563 --- Comment #3 from Andrew Pinski --- (In reply to Yi from comment #2) > (In reply to Andrew Pinski from comment #1) > > _5 =3D var_0_16(D) + var_6_18(D); > > invariant up to level 1, cost 1. > >=20 > > Basically because the cost is not high enough ... > >=20 > > If you use --param=3Dlim-expensive=3D1. then it will pull it out of t= he loop. > >=20 > > So the cost model is doing the correct thing here ... >=20 >=20 > Thank you very much for your prompt reply! It took me some time to confirm > our work. For Example 1, GCC does exactly what you say it does. But for > Example 2, it doesn't seem to work as expected. >=20 > We note that `(-(200 / var_10)) + (-var_8) + var_14 + var_2` as a whole c= an > be treated as a loop invariant, but gcc-trunk -O3 --param=3Dlim-expensive= =3D1 > does not: _4 =3D _2 + var_24_lsm.5_21; _6 =3D _4 + _5; So this is again reassociation with LIM, the same issue as PR 111560.=