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/102659] -O2 vectorization if-conversion produces wrong code for gcc.dg/torture/pr69760.c
Date: Mon, 11 Oct 2021 08:55:32 +0000	[thread overview]
Message-ID: <bug-102659-4-ftEdJnEbJb@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102659-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-10-11
            Summary|[false diagnosis] extra     |-O2 vectorization
                   |warning info after O2       |if-conversion produces
                   |vectorization for           |wrong code for
                   |gcc.dg/torture/pr69760.c    |gcc.dg/torture/pr69760.c
          Component|debug                       |tree-optimization
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|diagnostic                  |wrong-code

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
With -flto we have range info on the test_func function arguments (w/o -flto as
well if you make the function static).

  # RANGE [10000000, 10000000] NONZERO 10000000
  int L_16(D) = L;
  # RANGE [0, 400] NONZERO 508
  int m_13(D) = m;
  # RANGE [4, 4] NONZERO 4
  int n_15(D) = n;
  # RANGE [400, 400] NONZERO 400
  int N_12(D) = N;

the warning is emitted from the max_loop_iterations call in
vect_truncate_gather_scatter_offset, so it's not because something is
vectorized but because we run the vectorizer.  It's also emitted on
the if-converted code only because only then the address computation
of the a[L * k] = 0.0; store can be used to bound the number of iterations.

And indeed the address calculation overflows 32bit memory so this is a problem
with if-conversion since n == 4 and thus

      if (k >= 0 && k < n)
        a[L * k] = 0.0;

will never trigger in iteration 54.

if-conversion doesn't check whether it makes conditional integer overflow
non-conditional.  I think we might have a duplicate report of the problem
somewhere though.

  reply	other threads:[~2021-10-11  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09  4:54 [Bug debug/102659] New: [false diagnosis] extra warning info after O2 vectorization " crazylht at gmail dot com
2021-10-11  8:55 ` rguenth at gcc dot gnu.org [this message]
2021-10-11  8:57 ` [Bug tree-optimization/102659] -O2 vectorization if-conversion produces wrong code " rguenth at gcc dot gnu.org
2021-10-11  8:58 ` rguenth at gcc dot gnu.org
2021-10-11 10:31 ` rguenth at gcc dot gnu.org
2021-10-13 11:11 ` cvs-commit at gcc dot gnu.org
2021-10-13 11:12 ` rguenth at gcc dot gnu.org
2021-10-14 12:58 ` cvs-commit 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-102659-4-ftEdJnEbJb@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).