From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5C4D1396DC3B; Wed, 8 Jun 2022 19:44:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C4D1396DC3B From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105874] [13 Regression] Incorrect codegen and ICE since g:ed6fd2aed58f2cca99f15331bf68999c0e6df370 Date: Wed, 08 Jun 2022 19:44:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: roger at nextmovesoftware dot com X-Bugzilla-Target-Milestone: 13.0 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: Wed, 08 Jun 2022 19:44:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105874 --- Comment #7 from CVS Commits --- The master branch has been updated by Roger Sayle : https://gcc.gnu.org/g:b6e1373bd34aebbb512a03ea9a4e3c7acd955382 commit r13-1016-gb6e1373bd34aebbb512a03ea9a4e3c7acd955382 Author: Roger Sayle Date: Wed Jun 8 20:43:03 2022 +0100 PR middle-end/105874: Use EXPAND_MEMORY to fix ada bootstrap. Many thanks to Tamar Christina for filing PR middle-end/105874 indicati= ng that SPECcpu 2017's Leela is failing on x86_64 due to a miscompilation of FastBoard::is_eye. This function is much smaller and easier to work with than my previous hunt for the cause of the Ada bootstrap failures due to miscompilation somewhere in GCC (or one of the 131 places that the problematic form of optimization triggers during an ada bootstrap). It turns out the source of the miscompilation introduced by my recent patch is the distinction (during RTL expansion) of l-values and r-value= s. According to the documentation above expand_modifier, EXPAND_MEMORY should be used for lvalues (when a memory is required), and EXPAND_NORM= AL for rvalues when a constant is permissible. In what I'd like to consid= er a latent bug, the recursive call to expand_expr_real on line 11188 of expr.cc, in the case handling ARRAY_REF, COMPONENT_REF, BIT_FIELD_REF and ARRARY_RANGE_REF was passing EXPAND_NORMAL when it really required (the semantics of) EXPAND_MEMORY. All the time that VAR_DECLs were being returned as memory this was fine, but as soon as we're able to optimize sort arrays into immediate constants, bad things happen. In the test case from Leela, we notice that the array s_eyemask always has DImode constant value { 4, 64 }, which is useful as an rvalue, but not when we need to index it as an lvalue, as in s_eyemask[color]. This also explains why everything being accepted by immediate_const_ctor_p (during an ada bootstrap) looks reasonable, what's incorrect is that we don't know how these structs/arrays are to be used. The fix is to ensure that we call expand_expr with EXPAND_MEMORY when processing the VAR_DECL's returned by get_inner_reference. 2022-06-08 Roger Sayle gcc/ChangeLog PR middle-end/105874 * expr.cc (expand_expr_real_1) : New local variable tem_modifier for calculating the expand_modifier enum = to use for expanding tem. If tem is a VAR_DECL, use EXPAND_MEMORY. gcc/testsuite/ChangeLog PR middle-end/105874 * g++.dg/opt/pr105874.C: New test case.=