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 tree-optimization/110903] [12/13/14 Regression] Dead Code Elimination Regression
Date: Fri, 04 Aug 2023 18:37:42 +0000	[thread overview]
Message-ID: <bug-110903-4-jqh0uBK2Gq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110903-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-04
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.4
     Ever confirmed|0                           |1
           Keywords|                            |needs-bisection
            Summary|[14 Regression] Dead Code   |[12/13/14 Regression] Dead
                   |Elimination Regression      |Code Elimination Regression
                   |since r14-1597-g64d90d06d2d |

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. before r14-1597, there was a jump threading happening with respect
to:
  if (j_32 <= 0)
    goto <bb 9>; [50.00%]
  else
    goto <bb 8>; [50.00%]

  <bb 8> [local count: 238907556]:

  <bb 9> [local count: 477815112]:
  # iftmp.10_37 = PHI <_11(7), 0(8)>

But after, we change that into
iftmp.10_37 = _11 & (j_32 <= 0);

It just happens we depend on that due to:
  _43 = l_22 | _25;
  _39 = j_32 <= 0;
  _12 = ~_43;
  _44 = _12 & _39;


If we change the code to be:
```
void foo(void);
static signed char b, c;
static short e, f;
static int g = 41317;
static int(a)(int h, int i) { return h + i; }
static int(d)(int h, int i) { return i & h;}//i ? h : 0; }
short t = 10;
int main() {
    {
        signed char j;
        short k = t;
        for (; g >= 10; g = (short)g) {
            _Bool l = 1;
            int m = 0;
            j = 8 * k;
            k = j <= 0;
            f = c + 3;
            for (; c < 2; c = f) {
                signed char n = 4073709551615;
                if (!(((m) >= 0) && ((m) <= 0))) {
                    __builtin_unreachable();
                }
                if (g)
                    ;
                else {
                    if ((m = k, (b = a(d(l, k), e) && n) || l) < k) foo();
                    e = l = 0;
                }
            }
        }
    }
}
```

GCC 11 is able to remove the call to foo but GCC 12 cannot.
the IR for the part where the phiopt2 changes on the trunk is similar enough.

So this is instead a regression from GCC 11.

  parent reply	other threads:[~2023-08-04 18:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04 17:39 [Bug tree-optimization/110903] New: [14 Regression] Dead Code Elimination Regression since r14-1597-g64d90d06d2d theodort at inf dot ethz.ch
2023-08-04 17:58 ` [Bug tree-optimization/110903] " pinskia at gcc dot gnu.org
2023-08-04 18:37 ` pinskia at gcc dot gnu.org [this message]
2023-11-03 17:39 ` [Bug tree-optimization/110903] [12/13/14 Regression] Dead Code Elimination Regression tkoenig at gcc dot gnu.org
2023-11-03 17:51 ` pinskia at gcc dot gnu.org
2023-11-04 16:29 ` [Bug tree-optimization/110903] [12/13 " tkoenig at gcc dot gnu.org
2023-11-04 20:37 ` tkoenig at gcc dot gnu.org
2023-11-04 20:41 ` [Bug tree-optimization/110903] [12/13 Regression] Dead Code Elimination Regression since r12-4526-gd8edfadfc7a979 pinskia at gcc dot gnu.org
2024-05-07  7:41 ` 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-110903-4-jqh0uBK2Gq@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).