From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6EA663854804; Sun, 13 Dec 2020 23:11:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EA663854804 From: "kartikmohta at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/98265] New: gcc-10 has significantly worse code generated with -O2 compared to -O1 (or gcc-9 -O2) when using the Eigen C++ library Date: Sun, 13 Dec 2020 23:11:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kartikmohta 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 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: Sun, 13 Dec 2020 23:11:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98265 Bug ID: 98265 Summary: gcc-10 has significantly worse code generated with -O2 compared to -O1 (or gcc-9 -O2) when using the Eigen C++ library Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: kartikmohta at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- I was checking the generated assembly for the following simple code using t= he Eigen C++ library: #include Eigen::Matrix f(float x, float y, float z, float scale) { return Eigen::Matrix(x, y, z) * scale; } The Eigen::Matrix structure can be thought of as just a wrapper around an a= rray in this case. The preprocessed file is attached. When compiled with -O1 optimization, this generates the expected reasonable looking code, but when using -O2 it looks like the generated code is extrem= ely bad. The code generated by gcc-9.3 with -O2 also looks good. A quick compar= ison of the code generated by gcc 10.2 vs gcc 9.3 can be seen at https://godbolt.org/z/186c19. Upon bisecting this, it seems like the offending changes are from the pair = of commits which changed some of the inliner params: commit 1e83bd7003e03160b7d71fb959111e89b53446ab Author: Jan Hubicka Date: Sat Nov 23 05:13:23 2019 Convert inliner to new param infrastructure commit 9340d34599e6d5e7a6f3614de44b2c578b180c1b Author: Jan Hubicka Date: Sat Nov 23 05:11:25 2019 Convert inliner to function specific param infrastructure By playing with the optimization parameters, I saw that using either -fno-partial-inlining or --param early-inlining-insns=3D14 fixes the genera= ted code with -O2. Upon further investigation, it looks like earlier there were two separate params for early-inlining-insns for -O3 and -O2 but in the consider_split function (ipa-split.c) only the value for -O3 was used irrespective of the optimization level. This code was not changed when the inliner params chang= es were made leading to a much smaller value of param_early_inlining_insns bei= ng used in consider_split for -O2 now, which may be causing problems with inli= ning in this case.=