From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E60C53944406; Thu, 19 Mar 2020 06:55:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E60C53944406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584600915; bh=JerL9J4BKBJu0ZfMiMoz7bxDRiImjaxytOLpo4bnSjQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FJvLOYOJU168jiS8lfGqdjCEf75A4y6y5euR8gmKr164cF9LpVLP37qwvOTbMeC1G plXUOrxuKRNZBJh5HMHKZRkf5cyoeUEANJK4kamCxs5YSvwHUc597FwXDk69ZsxaKG xv7KFpopiCSvhW/Kx4uy+HgXFh5lNzL9ZriveaDw= From: "rguenth at gcc dot gnu.org" 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 06:55:15 +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: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: 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 06:55:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94216 --- Comment #5 from Richard Biener --- (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); We already applied STRIP_NOPS to arg0 > + if (arg0 !=3D op0) > + return fold_build2 (MEM_REF, type, arg0, op1); > + > /* MEM[&MEM[p, CST1], CST2] -> MEM[p, CST1 + CST2]. */ > if (TREE_CODE (arg0) =3D=3D ADDR_EXPR > && TREE_CODE (TREE_OPERAND (arg0, 0)) =3D=3D MEM_REF) > to catch all similar issues. Otherwise, we'd need to strip the useless t= ype > conversion at least in the case which triggers this: > return fold_build2 (MEM_REF, type, > build_fold_addr_expr (base), > int_const_binop (PLUS_EXPR, arg1, > size_int (coffset))); > a few lines below this, where build_fold_addr_expr now returns a NOP_EXPR > that we really want to strip again, even when op0 wasn't a NOP_EXPR. True. But note there could be a not useless type conversion here, for example for MEM [&a] and void *a for example. Here I think the better fix is (again) to use build1 and then in case the base was a MEM_REF recurse to the preceeding pattern. I'm testing such a patch.=