From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 94791385AC19; Tue, 6 Sep 2022 08:35:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94791385AC19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662453322; bh=uOdw+e7blac+Ua0LdTjBQkkvkcfO+qc7Ukgg2khWl7Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qWwFxODUpNwD10jnvTXWgq2KUA5MyE2vHk/CwmHZvs7bptYMl3qB1yKYaKJu3XNIf DSqOhxwqouhn51CDXAojSOeCoqDyOMrlNTyefjxqyRcMn4q93KiiGk2hS+EAKSsa6W xzdQyaYnMGlbXQDCNfAJ512JVBKsXC9a/CCLZOos= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106842] [12 Regression] misleading warning : iteration X invokes undefined behavior Date: Tue, 06 Sep 2022 08:35:13 +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: 12.2.1 X-Bugzilla-Keywords: diagnostic, missed-optimization, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc keywords 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=3D106842 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Keywords| |missed-optimization, | |wrong-code --- Comment #4 from Richard Biener --- Huh. static void infer_loop_bounds_from_signedness (class loop *loop, gimple *stmt) { ... low =3D lower_bound_in_type (type, type); high =3D upper_bound_in_type (type, type); value_range r; get_range_query (cfun)->range_of_expr (r, def); if (r.kind () =3D=3D VR_RANGE) { low =3D wide_int_to_tree (type, r.lower_bound ()); high =3D wide_int_to_tree (type, r.upper_bound ()); } record_nonwrapping_iv (loop, base, step, stmt, low, high, false, true); and record_nonwrapping_iv verifies that the IV stays in [low, high]. So this essentially means we are verifying range info here. We have # RANGE [0, 9] k_36 =3D PHI # RANGE [1, 9] k_20 =3D k_36 + 1; note the whole code is in a if (0) guarded block and we are executing ranger_vrp, in the substitute and fold phase (IIRC the old [E]VRP avoided to substitute/fold in dead code regions?). somebody needs to double-check if the range on the stmts is wrong, but depending on how VRP propagation treats unexecutable edges it might be GIGO anyhow. The "missed optimization" is that substitute-and-fold considers dead regions. "wrong code" is because either the range is bogus or the niter we derive from it is. needs a second eye=