public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-106842-4-fx37qkwt0s@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106842-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106842

Richard Biener <rguenth at gcc dot gnu.org> 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 <rguenth at gcc dot gnu.org> ---
Huh.

static void
infer_loop_bounds_from_signedness (class loop *loop, gimple *stmt)
{
...
  low = lower_bound_in_type (type, type);
  high = upper_bound_in_type (type, type);
  value_range r;
  get_range_query (cfun)->range_of_expr (r, def);
  if (r.kind () == VR_RANGE)
    {
      low = wide_int_to_tree (type, r.lower_bound ());
      high = 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 = PHI <k_20(18), 0(5)>
# RANGE [1, 9]
k_20 = 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

  parent reply	other threads:[~2022-09-06  8:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 21:43 [Bug c/106842] New: " franckbehaghel_gcc at protonmail dot com
2022-09-05 22:12 ` [Bug tree-optimization/106842] [12 Regression] " pinskia at gcc dot gnu.org
2022-09-05 22:20 ` pinskia at gcc dot gnu.org
2022-09-06  4:51 ` marxin at gcc dot gnu.org
2022-09-06  4:58 ` pinskia at gcc dot gnu.org
2022-09-06  8:35 ` rguenth at gcc dot gnu.org [this message]
2022-09-06  8:36 ` [Bug tree-optimization/106842] [12/13 " rguenth at gcc dot gnu.org
2022-12-20 15:23 ` rguenth at gcc dot gnu.org
2023-05-08 12:25 ` [Bug tree-optimization/106842] [12/13/14 " rguenth at gcc dot gnu.org
2024-03-15  0:50 ` [Bug tree-optimization/106842] [12 " law at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106842-4-fx37qkwt0s@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).