From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AD9B43858016; Mon, 14 Feb 2022 08:12:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD9B43858016 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104497] [11/12 Regression] Invalid gimple produced for (A?vect:vect)[i] Date: Mon, 14 Feb 2022 08:12:54 +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: 11.2.0 X-Bugzilla-Keywords: ice-on-valid-code, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.3 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: Mon, 14 Feb 2022 08:12:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104497 --- Comment #8 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:3f10e0d50b5e3b3f64bc9a1a29177518d5f4468d commit r12-7222-g3f10e0d50b5e3b3f64bc9a1a29177518d5f4468d Author: Richard Biener Date: Fri Feb 11 11:08:57 2022 +0100 middle-end/104497 - gimplification of vector indexing The following attempts to address gimplification of ... =3D VIEW_CONVERT_EXPR((i & 1) !=3D 0 ? inv : src)[i]; which is problematic since gimplifying the base object ? inv : src produces a register temporary but GIMPLE does not really support a register as a base for an ARRAY_REF (even though that's not strictly validated it seems as can be seen at -O0). Interestingly the C++ frontend avoids this issue by emitting the following GENERIC instead: ... =3D (i & 1) !=3D 0 ? VIEW_CONVERT_EXPR(inv)[i] : VIEW_CONVERT_EXPR(src)[i]; The proposed patch below fixes things up when using an rvalue as the base is OK by emitting a copy from a register base to a non-register one. The ?: as lvalue extension seems to be gone for C, C++ again unwraps the COND_EXPR in that case. 2022-02-11 Richard Biener PR middle-end/104497 * gimplify.cc (gimplify_compound_lval): Make sure the base is a non-register if needed and possible. * c-c++-common/torture/pr104497.c: New testcase.=