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/107114] [13 Regression] Failure to discover range results in bogus warning
Date: Thu, 22 Dec 2022 14:32:27 +0000	[thread overview]
Message-ID: <bug-107114-4-nX1SHPnhx5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107114-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-12-22

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed for the diagnostics.  But note the loop in question is basically

 for (a = 1; a != 0; a++)

so it iterates until we wrap to zero (a is 'short', the increment is in
'int' due to promotion so short wrap doesn't invoke undefined overflow).

That means the loop iterates >65000 times which means the repeated add
of 264487869 overflows.

At the point we emit this diagnostic this will always happen so the
diagnostic is correct?

We do fail to optimize if ((c += 264487869) == 9) though, but likely
because VRP no longer iterates.  c starts from 1 and we only add positive
numbers the range for it should be [1, +INF].  The entry to the line:
tail loop has this optimized and the add removed as dead code.  That's
what possibly happened before - we optimized this branch and thus DCEd
the add?

Anyhow, on x86_64 we mangle the whole thing a bit more than on arc-elf.

Huh, it looks like arc-elf disables GIMPLE loop optimizers.  I can reproduce
the diagnostic on x86_64 with -fno-tree-loop-optimize.
gcc/common/config/arc/arc-common.cc has

    { OPT_LEVELS_SIZE, OPT_ftree_loop_optimize, NULL, 0},

for whatever reason.  -ftree-loop-optimize "fixes" the diagnostic.

But as said, I think the diagnostic is correct.

  parent reply	other threads:[~2022-12-22 14:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01 17:59 [Bug tree-optimization/107114] New: " jeffreyalaw at gmail dot com
2022-10-01 18:01 ` [Bug tree-optimization/107114] " law at gcc dot gnu.org
2022-10-03 15:46 ` amacleod at redhat dot com
2022-10-03 17:37 ` law at gcc dot gnu.org
2022-10-03 18:18 ` amacleod at redhat dot com
2022-10-03 18:21 ` law at gcc dot gnu.org
2022-10-06  9:27 ` rguenth at gcc dot gnu.org
2022-12-22 14:32 ` rguenth at gcc dot gnu.org [this message]
2023-02-21 13:51 ` rguenth 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-107114-4-nX1SHPnhx5@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).