public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/114902] [14/15 Regression] wrong code at -O3 with "-fno-tree-vrp -fno-expensive-optimizations -fno-tree-dominator-opts" on x86_64-linux-gnu
Date: Wed, 01 May 2024 05:12:13 +0000	[thread overview]
Message-ID: <bug-114902-4-QzM608EeIl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114902-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is a reduced testcase:
```

[[gnu::noipa]]
int f(int b)
{
    int tt1 = ~b;
    int t = 1 & tt1;
    int e = -t;
    int tt = e >= -1;
    if (tt) return 0;
    __builtin_trap();
}

int main()
{
  for(int i = -1;i < 2; i++)
    f(i);
}
```

Note ` -O1 -fno-tree-fre -fno-tree-forwprop -fno-tree-ccp 
-fno-tree-dominator-opts` is needed to reproduce it with this one. The generate
gimple is the same between GCC 13 and 14 here.

But the first difference is in combine:
```
Trying 7 -> 8:
    7: {r106:SI=r105:SI&0x1;clobber flags:CC;}
      REG_DEAD r105:SI
      REG_UNUSED flags:CC
    8: {r107:SI=-r106:SI;clobber flags:CC;}
      REG_DEAD r106:SI
      REG_UNUSED flags:CC
Successfully matched this instruction:
(parallel [
        (set (reg:SI 107 [ e_5 ])
            (sign_extract:SI (reg:SI 105 [ tt1_3 ])
                (const_int 1 [0x1])
                (const_int 0 [0])))
        (clobber (reg:CC 17 flags))
    ])
allowing combination of insns 7 and 8
original costs 4 + 4 = 8
replacement cost 4
deferring deletion of insn with uid = 7.
modifying insn i3     8: {r107:SI=sign_extract(r105:SI,0x1,0);clobber
flags:CC;}
      REG_DEAD r105:SI

```

This is correct but it goes down hill after like as I mentioned in comment #2.

So it does look like a latent bug after all.


If someone does a bisect of this testcase, I am 99% sure you find
r14-4810-ge28869670c9879 is where the failure was introduced. For the original
testcase and the one in comment #1 might find a different commit due to gimple
level being different.

  parent reply	other threads:[~2024-05-01  5:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 22:13 [Bug tree-optimization/114902] New: " zhendong.su at inf dot ethz.ch
2024-05-01  2:06 ` [Bug target/114902] [14/15 Regression] " pinskia at gcc dot gnu.org
2024-05-01  2:22 ` [Bug rtl-optimization/114902] " pinskia at gcc dot gnu.org
2024-05-01  2:34 ` pinskia at gcc dot gnu.org
2024-05-01  5:12 ` pinskia at gcc dot gnu.org [this message]
2024-05-01  5:29 ` pinskia at gcc dot gnu.org
2024-05-03  8:14 ` segher at gcc dot gnu.org
2024-05-03  8:38 ` pinskia at gcc dot gnu.org
2024-05-07  7:45 ` rguenth at gcc dot gnu.org
2024-05-09  9:48 ` segher at gcc dot gnu.org
2024-05-09  9:49 ` segher at gcc dot gnu.org
2024-05-14 20:09 ` segher at gcc dot gnu.org
2024-05-14 22:04 ` pinskia at gcc dot gnu.org
2024-05-15 16:44 ` cvs-commit at gcc dot gnu.org
2024-05-15 16:54 ` [Bug rtl-optimization/114902] [14 " jakub at gcc dot gnu.org
2024-06-04 14:26 ` cvs-commit at gcc dot gnu.org
2024-06-04 14:28 ` jakub at gcc dot gnu.org
2024-06-11  6:17 ` cvs-commit at gcc dot gnu.org
2024-06-11 10:38 ` cvs-commit at gcc dot gnu.org
2024-06-20 13:23 ` 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-114902-4-QzM608EeIl@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).