From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 69DC43858D33; Mon, 17 Jul 2023 09:55:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69DC43858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689587755; bh=eXpDOqHO8q+cA3ZjN2jmwWAmlNE6QN12Xm/ES76dS5M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sjVOsSu5RlF1+EwhsFloMbN0pyjktVNjYhUUAmySgurvkrzsBJR1K9kRMf/6/n/Ep aSNMGB4YtIDDYAbVutfyU/4cD8RkNY4kgbCXSqdMFhgc5ZrUC0xHpBBS/JmR59MM7R wc7w5SAPdfxYC22Rm8t/1kEcIxgCcnYllMjoEs6M= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110204] [14 Regression] Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior) Date: Mon, 17 Jul 2023 09:55:53 +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: 14.0 X-Bugzilla-Keywords: diagnostic, missed-optimization, needs-bisection, needs-reduction X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110204 --- Comment #5 from Richard Biener --- Yeah, the issue is that PRE figures out a new value here but we've already = done value-numbering so we can't alter the "old" solution here. So what we do is add a '0' with value '_42' (instead of value '0'). This "second order" value numbering leaves more opportunities on the plate. It was IMHO cleaner to insert a pretmp_163 =3D 0; than substituting '0' everywhere but then leaving around the third order optimizations in case we had _42 + 1 that would then simplify to sth =3D 1 = ... Previously we'd have inserted a degenerate PHI, now we get these kind of copies. "Now" is for a long time so this isn't new for PRE at least. We could "hack" this by doing diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 11061a374a2..effb4f4de73 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -6615,6 +6615,13 @@ eliminate_dom_walker::eliminate_push_avail (basic_bl= ock, tree op) if (avail[SSA_NAME_VERSION (valnum)]) pushop =3D avail[SSA_NAME_VERSION (valnum)]; avail_stack.safe_push (pushop); + if (gassign *ass =3D dyn_cast (SSA_NAME_DEF_STMT (op))) + if (gimple_assign_rhs_class (ass) =3D=3D GIMPLE_SINGLE_RHS) + { + tree rhs1 =3D gimple_assign_rhs1 (ass); + if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) =3D=3D SSA_NAME) + op =3D rhs1; + } avail[SSA_NAME_VERSION (valnum)] =3D op; } }=