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/105198] [11/12 Regression] Wrong code for C loop (GCC 12 -O2, GCC 11 -O3)
Date: Fri, 08 Apr 2022 09:04:07 +0000	[thread overview]
Message-ID: <bug-105198-4-eirQJlnKpa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105198-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So it's predictive commoning that triggers the miscompile, it works with
-fno-predictive-commoning.  predcom does

--- a-t.c.167t.dce6     2022-04-08 10:59:28.824746581 +0200
+++ a-t.c.168t.pcom     2022-04-08 10:59:28.824746581 +0200
@@ -4,6 +4,7 @@
 __attribute__((noipa, noinline, noclone, no_icf))
 void next_set (int * x, int n, int k)
 {
+  int D__lsm0.19;
   vector(4) int * vectp.18;
   vector(4) int * vectp.17;
   vector(4) int vect_tmp_55.16;
@@ -117,6 +118,7 @@
   [t.c:43:8] _13 = [t.c:43:8] *_12;
   [t.c:43:11] _14 = _13 + 1;
   [t.c:43:11] [t.c:43:8] *_12 = _14;
+  D__lsm0.19_72 = _14;
   [t.c:40:17] if (j_49 > 0)
     goto <bb 19>; [94.50%]
   else
@@ -132,11 +134,12 @@

   <bb 6> [local count: 1014686026]:
   # j_73 = PHI <[t.c:42:8] j_49(19), [t.c:34:7] j_46(15)>
-  # tmp_75 = PHI <[t.c:43:11] _14(19), [t.c:35:9] _8(15)>
+  # D__lsm0.19_77 = PHI <D__lsm0.19_72(19), _8(15)>
+  tmp_75 = D__lsm0.19_77;
   [t.c:40:21] _16 = (long unsigned int) j_73;
   [t.c:40:21] _17 = _16 * 4;
   [t.c:40:21] _18 = x_47(D) + _17;
-  [t.c:40:21] _19 = [t.c:40:21] *_18;
+  [t.c:40:21] _19 = D__lsm0.19_77;
   [t.c:40:39] _21 = j_46 - j_73;
   [t.c:40:30] _22 = n_41(D) - _21;
   [t.c:40:17] if (_19 >= _22)

which at first doesn't look wrong, but when disabling PRE (which without
vectorization would do the same transform) the issue also shows up w/o
vectorization

 -O2 -fno-tree-vectorize -fno-tree-pre -fpredictive-commoning

  parent reply	other threads:[~2022-04-08  9:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 17:02 [Bug middle-end/105198] New: " tomas.kalibera at gmail dot com
2022-04-08  8:32 ` [Bug tree-optimization/105198] [11/12 Regression] " rguenth at gcc dot gnu.org
2022-04-08  8:45 ` jakub at gcc dot gnu.org
2022-04-08  9:04 ` rguenth at gcc dot gnu.org [this message]
2022-04-08  9:12 ` rguenth at gcc dot gnu.org
2022-04-08 10:55 ` rguenth at gcc dot gnu.org
2022-04-08 12:10 ` [Bug tree-optimization/105198] [9/10/11/12 " rguenth at gcc dot gnu.org
2022-04-08 12:18 ` cvs-commit at gcc dot gnu.org
2022-04-08 12:20 ` [Bug tree-optimization/105198] [9/10/11 " rguenth at gcc dot gnu.org
2022-04-08 13:00 ` cvs-commit at gcc dot gnu.org
2022-04-08 13:00 ` [Bug tree-optimization/105198] [9/10 " rguenth at gcc dot gnu.org
2022-04-08 17:06 ` tomas.kalibera at gmail dot com
2022-05-06 12:47 ` cvs-commit at gcc dot gnu.org
2022-05-27  9:53 ` [Bug tree-optimization/105198] [9 " 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-105198-4-eirQJlnKpa@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).