From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C807038930E1; Fri, 24 Apr 2020 09:03:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C807038930E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587719035; bh=Ucl2R/U6pkcPgrUCebyx+cg/lX2d2bcnePUYXXwzyEI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Qg2Oc3JLUYb0iIwIglCEnarYjlQa4V+GwZWHx0kAE1/9pTxYWwWnVvU6COd6RCn78 uBSUsj36Gq4D4MWPXlUQzqCCUGaGmiI8ql/OFGFWfhr5ZVfxweX0UEd/hz916T8DAk iP8VfpEY3Q8CWGJ9akWr++v0QMlpXkoc1h/aL520= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94734] [10 Regression] Program crashes when compiled with -O2 since r10-1892-gb9ef6a2e04bfd013 Date: Fri, 24 Apr 2020 09:03:55 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned 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: Fri, 24 Apr 2020 09:03:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94734 --- Comment #12 from rguenther at suse dot de --- On Fri, 24 Apr 2020, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94734 >=20 > --- Comment #11 from Jakub Jelinek --- > If we don't want to revert the change completely, could we perhaps do: > --- gcc/tree-ssa-phiopt.c.jj 2020-03-19 10:23:50.542872359 +0100 > +++ gcc/tree-ssa-phiopt.c 2020-04-24 10:54:10.341716841 +0200 > @@ -2237,10 +2237,26 @@ cond_store_replacement (basic_block midd > whose value is not available readily, which we want to avoid. */ > if (!nontrap->contains (lhs)) > { > - /* If LHS is a local variable without address-taken, we could > - always safely move down the store. */ > - tree base =3D get_base_address (lhs); > - if (!auto_var_p (base) || TREE_ADDRESSABLE (base)) > + /* If LHS is an access to a local variable without address-taken > + or its part and the access is provably within the bounds of the > + local variable, we could always safely move down the store. */ > + HOST_WIDE_INT offset, size, decl_size; > + bool reverse; > + tree base =3D get_ref_base_and_extent_hwi (lhs, &offset, &size, > + &reverse); > + if (base =3D=3D NULL_TREE || !auto_var_p (base) || TREE_ADDRESSABL= E (base)) > + return false; > + if (!DECL_SIZE (base) > + || !tree_fits_shwi_p (DECL_SIZE (base))) > + return false; > + decl_size =3D tree_to_shwi (DECL_SIZE (base)); > + if (offset < 0 > + || size < 0 > + || decl_size < 0 > + || offset >=3D decl_size > + || size > decl_size > + || ((unsigned HOST_WIDE_INT) offset + size > + > (unsigned HOST_WIDE_INT) decl_size)) > return false; > } That should be roughly equivalent to if (!nontrap->contains (lhs) || !tree_could_trap_p (lhs)) which for ARRAY_REFs checks in_array_bounds_p.=