From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 28076385E824; Thu, 19 Mar 2020 11:51:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28076385E824 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584618714; bh=FMEsvIlQBF6bNaZ7Nh9KK4nJkcs7YbI18CTy8N0ihp8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Gkk8iZGW/zKPODiX8pM/Alo54Ixj2L6JDIxATTHDTw7gq2N8IVoIm4uFUynr4cDjv YUJnpxEfzwrLMO1Gdzs58M5luLO+pevLgbnOkAN2drR+VZ5ff0Iu4chsP+PKyYZt2M 6G8e6R3Czo5Z1mWu3vUiZXxpnIeDP5Yp7WyIjLMQ= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94216] [10 Regression] ICE in maybe_canonicalize_mem_ref_addr, at gimple-fold.c:4899 since r10-7237-g4e3d3e40726e1b68bf52fa205c68495124ea60b8 Date: Thu, 19 Mar 2020 11:51: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: 10.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.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: Thu, 19 Mar 2020 11:51:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94216 --- Comment #9 from rguenther at suse dot de --- On Thu, 19 Mar 2020, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94216 >=20 > --- Comment #8 from Jakub Jelinek --- > (In reply to Richard Biener from comment #5) > > (In reply to Jakub Jelinek from comment #1) > > > I wonder if we shouldn't do: > > > --- gcc/fold-const.c.jj 2020-03-18 12:47:36.000000000 +0100 > > > +++ gcc/fold-const.c 2020-03-18 17:34:14.586455801 +0100 > > > @@ -82,6 +82,7 @@ along with GCC; see the file COPYING3. > > > #include "attribs.h" > > > #include "tree-vector-builder.h" > > > #include "vec-perm-indices.h" > > > +#include "tree-ssa.h" > > >=20=20 > > > /* Nonzero if we are folding constants inside an initializer; zero > > > otherwise. */ > > > @@ -10262,6 +10263,10 @@ fold_binary_loc (location_t loc, enum tr > > > switch (code) > > > { > > > case MEM_REF: > > > + STRIP_USELESS_TYPE_CONVERSION (arg0); > >=20 > > We already applied STRIP_NOPS to arg0 >=20 > Though, if we don't want to strip non-useless conversions, that is wrong = even > for the two special cases we have afterwards. > So, shouldn't case MEM_REF: start then with > arg0 =3D op0; > STRIP_USELESS_TYPE_CONVERSION (arg0); > arg1 =3D op1; > ? While we "abuse" fold_binary (MEM_REF,...) to make MEM_REFs valid we still expect some basic hygiene there.. > Or fold_convert to the type of op0 if the type conversion isn't useless? > Also, isn't the arg1 handling incorrect or at least dangerous? > I mean, if it does int_const_binop (PLUS_EXPR, arg1, ...) in both cases > then it will have the type of arg1 which is op1 after STRIP_NOPS, so coul= d have > completely different type. One needs to hope that the last argument to > fold_binary_loc of MEM_REF will always be an INTEGER_CST from which nothi= ng can > be stripped... ..for example INTEGER_CST 2nd argument (implicit in the use of int_const_binop). For the 2nd arg we could be more explicit and instead of arg1 use op1. Likewise we should probably use if (TREE_CODE (op0) =3D=3D ADDR_EXPR && TREE_CODE (TREE_OPERAND (op0, 0)) =3D=3D MEM_REF) that is, we don't even expect to need to strip nops here. I'll try to bootstrap/test such changes to see where other possible issues in fold_build_addr_expr callers lie...=