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 middle-end/111799] [14 Regression] Missed Dead Code Elimination since  r14-2365-g2e406f0753e
Date: Wed, 18 Oct 2023 23:55:38 +0000	[thread overview]
Message-ID: <bug-111799-4-QbGOuttK6p@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111799-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|tree-optimization           |middle-end
     Ever confirmed|0                           |1
           Keywords|                            |TREE
   Last reconfirmed|                            |2023-10-18

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Theodoros Theodoridis from comment #4)
> Oops, there was a bug in my reduction, here's the fixed code:
> 
> https://godbolt.org/z/shxffzs8E
> 
> void foo(void);
> typedef unsigned short uint16_t;
> static int b;
> static int ****c;
> static int *f = &b;
> static int *****ad;
> static char(a)(char g, char h) { return g + h; }
> static char(d)(char g, char h) { return g * h; }
> static void(e)(uint16_t g) {
>     if (!(((g) >= 1) && ((g) <= 65459))) {
>         __builtin_unreachable();
>     }
> }
> int main() {
>     b = 0;
>     for (;; b = 1) {
>         char i = d(126 | 1, 205);
>         e(i);
>         short j;
>         int k = *f;
>         j = -21;
>         for (; j; j = a(j, 7)) e((j ^ k && *f) <= *f);
>         if (b) break;
>         ad = &c;
>     }
>     if (ad)
>         ;
>     else
>         foo();
>     ;
> }


Confirmed with this testcase but what is interesting is that the optimization
of calling foo away does NOT happen at the gimple level but at the RTL level
and just happens on x86_64 but NOT on aarch64.

on aarch64 for GCC 13, we even have:
        mov     w0, 1
        str     wzr, [x1, #:lo12:.LANCHOR0]
        cbz     w0, .L13

Which is obvious should have been removed ...

Anyways this is a missed jump threading that should have happened at the gimple
level. I have not looked into why it is not done.

  parent reply	other threads:[~2023-10-18 23:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 15:46 [Bug tree-optimization/111799] New: " theodort at inf dot ethz.ch
2023-10-13 15:48 ` [Bug tree-optimization/111799] " pinskia at gcc dot gnu.org
2023-10-13 15:50 ` pinskia at gcc dot gnu.org
2023-10-13 15:52 ` pinskia at gcc dot gnu.org
2023-10-16  4:08 ` pinskia at gcc dot gnu.org
2023-10-17 11:08 ` theodort at inf dot ethz.ch
2023-10-18 23:55 ` pinskia at gcc dot gnu.org [this message]
2024-03-07 21:04 ` [Bug middle-end/111799] " law at gcc dot gnu.org
2024-03-09  5:43 ` law at gcc dot gnu.org
2024-05-07  7:42 ` [Bug middle-end/111799] [14/15 " 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-111799-4-QbGOuttK6p@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).