public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
@ 2023-08-08  9:24 scherrer.sv at gmail dot com
  2023-08-08  9:51 ` [Bug tree-optimization/110942] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: scherrer.sv at gmail dot com @ 2023-08-08  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110942
           Summary: [14 Regression] Dead Code Elimination Regression at
                    -O3 since r14-1165-g257c2be7ff8
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int b, c;
static short d;
static char e;
void bar49_(void);
void bar115_(void);
void bar42_(void);
void foo(void);
static short(a)(short f, short g) { return f + g; }
static int h() {
  short i = 0;
  char j;
  int k;
l:
  k = 0;
  if (i)
    bar42_();
  i = 0;
  for (; i != 8; i = a(i, 8)) {
    if (e)
      bar49_();
    if (0 >= i)
      c = 0;
    if (!k) {
      j = 6;
      for (; j >= 0; j--) {
        k = 0;
        for (; k <= 0; k++) {
          if (!(j >= 5))
            bar115_();
          for (; d; d = 0) {
            if (!j)
              foo();
            if (j)
              break;
          }
          if (i)
            break;
        }
        if (c)
          return j;
        c = 2;
        if (b)
          goto l;
      }
    }
  }
  return 0;
}
int main() { h(); }

gcc-25c4b1620eb (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
-----------------------------------------------------------------------
gcc-25c4b1620ebc10fceabd86a34fdbbaf8037e7e82 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB2:
        .cfi_startproc
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        xorl    %eax, %eax
        movl    $6, %ebx
.L2:
        movl    %eax, c(%rip)
        cmpb    $4, %bl
        jne     .L18
.L7:
        call    bar115_
        cmpw    $0, d(%rip)
        je      .L8
        testb   %bl, %bl
        jne     .L8
        call    foo
        movl    c(%rip), %edx
        xorl    %eax, %eax
        movw    %ax, d(%rip)
        testl   %edx, %edx
        jne     .L5
        movl    $2, c(%rip)
.L5:
        xorl    %eax, %eax
        popq    %rbx
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        ret
.L18:
        .cfi_restore_state
        testl   %eax, %eax
        jne     .L5
        subl    $1, %ebx
        movl    $2, %eax
        jmp     .L2
.L8:
        cmpl    $0, c(%rip)
        jne     .L5
        movl    $2, c(%rip)
        subl    $1, %ebx
        cmpb    $-1, %bl
        jne     .L7
        jmp     .L5
---------- END OUTPUT ---------

-----------------------------------------------------------------------
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB2:
        .cfi_startproc
        movl    $2, c(%rip)
        xorl    %eax, %eax
        ret
---------- END OUTPUT ---------

-----------------------------------------------------------------------
Bisects to r14-1165-g257c2be7ff8

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
@ 2023-08-08  9:51 ` rguenth at gcc dot gnu.org
  2023-08-16 19:20 ` amacleod at redhat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-08  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
  2023-08-08  9:51 ` [Bug tree-optimization/110942] " rguenth at gcc dot gnu.org
@ 2023-08-16 19:20 ` amacleod at redhat dot com
  2023-08-16 19:34 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2023-08-16 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 55743
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55743&action=edit
patch to revert the change

Although the bisection stopped at this change, it does not appear to be the
underlying culprit.  The attached patch will revert that change (its pretty
simple) and the problem still exists.. so something other than that presumably
caused it.

I Also presume this is the first change going backwards that shows the issue,
is it possible to find the *first* change since gcc 13 was branched that caused
the issue?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
  2023-08-08  9:51 ` [Bug tree-optimization/110942] " rguenth at gcc dot gnu.org
  2023-08-16 19:20 ` amacleod at redhat dot com
@ 2023-08-16 19:34 ` pinskia at gcc dot gnu.org
  2023-08-16 20:04 ` amacleod at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-16 19:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-16
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
The problem seems like missing jump threading:
  <bb 9> [local count: 114235120]:
  # j_4 = PHI <j_31(11), 6(2)>
  if (j_4 <= 4)
    goto <bb 3>; [84.84%]
  else
    goto <bb 10>; [15.16%]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
                   ` (2 preceding siblings ...)
  2023-08-16 19:34 ` pinskia at gcc dot gnu.org
@ 2023-08-16 20:04 ` amacleod at redhat dot com
  2023-11-24  4:31 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2023-08-16 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
The original revision listed, I narrowed down to a single instance where the
new code did something that makes a difference
we determine that in stmt
  stmt _8 = (int) i_10;
which originally had a range of int [0, 0][8, 8] MASK 0x8 VALUE 0x0,
the new code allows it to determine that the result is actually now int [0, 0],
which allows stmt_8 to be propagated as "0" now.. and thus dead. 
It was also dead before, but stayed around for a fe wpasses because it wasnt a
constant, so wasn't put in the "let VRP kill this stmt because it was fully
propagated as a constant" list.

The only difference in the IL as a result is the block which contained that
stmt has a phi:
>   <bb 26> :
>   # k_14 = PHI <k_15(10), k_13(25)>
>   _8 = (int) i_10;
and with the current trunk, we remove that block, which causes the fallthru
block to have an extra incoming edge:

<   # i_10 = PHI <0(4), 8(25), 8(10), 0(3)>
<   # k_15 = PHI <0(4), k_13(25), k_15(10), 0(3)>
---
>   # i_10 = PHI <0(4), 8(26), 0(3)>
>   # k_15 = PHI <0(4), k_14(26), 0(3)>


That is literally the only difference coming out of EVRP, so perhaps the extra
edge coming into the block is causing some threading issues?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
                   ` (3 preceding siblings ...)
  2023-08-16 20:04 ` amacleod at redhat dot com
@ 2023-11-24  4:31 ` pinskia at gcc dot gnu.org
  2024-01-10 14:44 ` jamborm at gcc dot gnu.org
  2024-03-04  4:50 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-24  4:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Seems to be fixed on the trunk.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
                   ` (4 preceding siblings ...)
  2023-11-24  4:31 ` pinskia at gcc dot gnu.org
@ 2024-01-10 14:44 ` jamborm at gcc dot gnu.org
  2024-03-04  4:50 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-10 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
                 CC|                            |jamborm at gcc dot gnu.org

--- Comment #5 from Martin Jambor <jamborm at gcc dot gnu.org> ---
This has been fixed with r14-5109-ga291237b628f41 (Andrew MacLeod: Remove
simple ranges from trailing zero bitmasks.)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/110942] [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8
  2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
                   ` (5 preceding siblings ...)
  2024-01-10 14:44 ` jamborm at gcc dot gnu.org
@ 2024-03-04  4:50 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-04  4:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #6 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Per c#5

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-04  4:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-08  9:24 [Bug tree-optimization/110942] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-1165-g257c2be7ff8 scherrer.sv at gmail dot com
2023-08-08  9:51 ` [Bug tree-optimization/110942] " rguenth at gcc dot gnu.org
2023-08-16 19:20 ` amacleod at redhat dot com
2023-08-16 19:34 ` pinskia at gcc dot gnu.org
2023-08-16 20:04 ` amacleod at redhat dot com
2023-11-24  4:31 ` pinskia at gcc dot gnu.org
2024-01-10 14:44 ` jamborm at gcc dot gnu.org
2024-03-04  4:50 ` law at gcc dot gnu.org

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).