From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0AA1638930D5; Fri, 24 Apr 2020 08:59:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AA1638930D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587718778; bh=GRgie6khUsan+GLWf+/JQtChqGKIr8N6cL6CKW2CE4w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N4D/MoVhDPQLZzjb593WCFfkZlFOV+GhX9e+3EGNKgjUr1ZYjERpS2lXq5tDFmps/ 9deG2a8YUY53TD+kWS7PbJiApWrThNMISspFgx3nU/pxSBw6Bz/0wQIdUAxx+PffTc +6ISGYUyiruOdVTj4nFhLZxq+p493tHJSJA68at8= From: "jakub at gcc dot gnu.org" 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 08:59:37 +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: jakub at gcc dot gnu.org 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 08:59:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94734 --- 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_ADDRESSABLE = (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; } + xfail the tests from the PR89430 because they all need the nontrap ARRAY_= REF etc. handling? With that, in the above testcase baz is still cselim optimized , but foo and bar are not. bar is still miscompiled by some other optimization though (a= nd GCC 9 didn't do that), so we have some other regression.=