public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
@ 2022-11-22 17:59 yann at ywg dot ch
  2022-11-22 21:21 ` [Bug tree-optimization/107823] [13 Regression] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: yann at ywg dot ch @ 2022-11-22 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107823
           Summary: Dead Code Elimination Regression at -Os (trunk vs.
                    12.2.0)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yann at ywg dot ch
  Target Milestone: ---

Created attachment 53946
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53946&action=edit
Code

cat case.c #230633
int a;
void bar64_(void);
void foo();
int main() {
  char b = a = 6;
  for (; a; a = 0) {
    bar64_();
    b = 0;
  }
  if (b <= 0)
    ;
  else
    foo();
}

`gcc-e4faee8d02ec5d65bf418612f7181823eb08c078 (trunk) -Os` can not eliminate
`foo` but `gcc-releases/gcc-12.2.0 -Os` can.

`gcc-e4faee8d02ec5d65bf418612f7181823eb08c078 (trunk) -Os -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        pushq   %rcx
        .cfi_def_cfa_offset 16
        movl    $6, %eax
        movb    $6, %dl
.L2:
        movl    %eax, a(%rip)
        testl   %eax, %eax
        je      .L10
        call    bar64_
        xorl    %eax, %eax
        xorl    %edx, %edx
        jmp     .L2
.L10:
        testb   %dl, %dl
        je      .L4
        call    foo
.L4:
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


`gcc-releases/gcc-12.2.0 -Os -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    $6, a(%rip)
        call    bar64_
        xorl    %edx, %edx
        xorl    %eax, %eax
        movl    %edx, a(%rip)
        popq    %rcx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=353fd1ec3df92fbe66ce1513c5a86bdd5c5e22d1

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

* [Bug tree-optimization/107823] [13 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
@ 2022-11-22 21:21 ` pinskia at gcc dot gnu.org
  2022-11-23  9:52 ` marxin at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-22 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Dead Code Elimination       |[13 Regression] Dead Code
                   |Regression at -Os (trunk    |Elimination Regression at
                   |vs. 12.2.0)                 |-Os (trunk vs. 12.2.0)
   Target Milestone|---                         |13.0

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

* [Bug tree-optimization/107823] [13 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
  2022-11-22 21:21 ` [Bug tree-optimization/107823] [13 Regression] " pinskia at gcc dot gnu.org
@ 2022-11-23  9:52 ` marxin at gcc dot gnu.org
  2022-11-23 20:48 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-11-23  9:52 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-11-23
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

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

* [Bug tree-optimization/107823] [13 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
  2022-11-22 21:21 ` [Bug tree-optimization/107823] [13 Regression] " pinskia at gcc dot gnu.org
  2022-11-23  9:52 ` marxin at gcc dot gnu.org
@ 2022-11-23 20:48 ` rguenth at gcc dot gnu.org
  2022-11-24  9:58 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-23 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug tree-optimization/107823] [13 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (2 preceding siblings ...)
  2022-11-23 20:48 ` rguenth at gcc dot gnu.org
@ 2022-11-24  9:58 ` rguenth at gcc dot gnu.org
  2023-04-08 14:40 ` law at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-24  9:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW
                 CC|                            |aldyh at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think it's working as intended now - in GCC 12 we did

Checking profitability of path (backwards):  bb:4 (4 insns) bb:3 (latch)
  Control statement insns: 2
  Overall: 2 insns
  [4] Registering jump thread: (3, 4) incoming edge;  (4, 5) nocopy;
path: 3->4->5 SUCCESS

while on trunk we have

Checking profitability of path (backwards):  bb:4 (4 insns) bb:3 (latch)
  Control statement insns: 2
  Overall: 2 insns

Checking profitability of path (backwards):   FAIL: Jump-thread path not
considered: duplication of 2 insns is needed and optimizing for size.
path: 3->4->xx REJECTED

so the fix works exactly as intended.

The pattern of a loop where the control stmt is statically resolvable
both in the first and the second iteration would likely need special
heuristical treatment, allowing to see the full 2->4->3->4->5 thread
and anticipating elimination of the conditionals and the original
block copies.  But the machinery isn't set up for this at all.

It works just fine at -O2.

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

* [Bug tree-optimization/107823] [13 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (3 preceding siblings ...)
  2022-11-24  9:58 ` rguenth at gcc dot gnu.org
@ 2023-04-08 14:40 ` law at gcc dot gnu.org
  2023-04-26  6:57 ` [Bug tree-optimization/107823] [13/14 " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: law at gcc dot gnu.org @ 2023-04-08 14:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
           Priority|P3                          |P2

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (4 preceding siblings ...)
  2023-04-08 14:40 ` law at gcc dot gnu.org
@ 2023-04-26  6:57 ` rguenth at gcc dot gnu.org
  2023-07-27  9:24 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26  6:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |13.2

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.1 is being released, retargeting bugs to GCC 13.2.

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (5 preceding siblings ...)
  2023-04-26  6:57 ` [Bug tree-optimization/107823] [13/14 " rguenth at gcc dot gnu.org
@ 2023-07-27  9:24 ` rguenth at gcc dot gnu.org
  2023-11-24  3:42 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.2                        |13.3

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.2 is being released, retargeting bugs to GCC 13.3.

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0)
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (6 preceding siblings ...)
  2023-07-27  9:24 ` rguenth at gcc dot gnu.org
@ 2023-11-24  3:42 ` pinskia at gcc dot gnu.org
  2024-01-10 17:55 ` [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f jamborm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-24  3:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (7 preceding siblings ...)
  2023-11-24  3:42 ` pinskia at gcc dot gnu.org
@ 2024-01-10 17:55 ` jamborm at gcc dot gnu.org
  2024-01-11  0:44 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-10 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> ---
This has been fixed by commit r14-4089-gd45ddc2c04e471 (Richard Biener:
tree-optimization/111294 - backwards threader PHI costing).

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (8 preceding siblings ...)
  2024-01-10 17:55 ` [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f jamborm at gcc dot gnu.org
@ 2024-01-11  0:44 ` pinskia at gcc dot gnu.org
  2024-01-13  4:39 ` cvs-commit at gcc dot gnu.org
  2024-01-13  4:40 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-11  0:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I will commit a testcase for this one and close it as fixed since it was a
missing jump threading that is now doing it correctly.

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (9 preceding siblings ...)
  2024-01-11  0:44 ` pinskia at gcc dot gnu.org
@ 2024-01-13  4:39 ` cvs-commit at gcc dot gnu.org
  2024-01-13  4:40 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-13  4:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:34a827039fabcf24ce78da25984a1cc8be7ca2c3

commit r14-7221-g34a827039fabcf24ce78da25984a1cc8be7ca2c3
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Fri Jan 12 20:24:34 2024 -0800

    Add a few testcases for fix missed optimization regressions

    Adds a few new testcases for some missed optimization regressions.
    The analysis on how each should be optimized is in the testcases
    themselves (and in the bug report).

    Committed as obvious after running the testsuite to make sure they pass.

            PR tree-optimization/107823
            PR tree-optimization/110768
            PR tree-optimization/110941
            PR tree-optimization/110450
            PR tree-optimization/110841

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/ssa-thread-22.c: New test.
            * gcc.dg/tree-ssa/vrp-loop-1.c: New test.
            * gcc.dg/tree-ssa/vrp-loop-2.c: New test.
            * gcc.dg/tree-ssa/vrp-unreachable-1.c: New test.
            * gcc.dg/tree-ssa/vrp-unreachable-2.c: New test.

    Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>

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

* [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f
  2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
                   ` (10 preceding siblings ...)
  2024-01-13  4:39 ` cvs-commit at gcc dot gnu.org
@ 2024-01-13  4:40 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-13  4:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.3                        |14.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2024-01-13  4:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 17:59 [Bug tree-optimization/107823] New: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) yann at ywg dot ch
2022-11-22 21:21 ` [Bug tree-optimization/107823] [13 Regression] " pinskia at gcc dot gnu.org
2022-11-23  9:52 ` marxin at gcc dot gnu.org
2022-11-23 20:48 ` rguenth at gcc dot gnu.org
2022-11-24  9:58 ` rguenth at gcc dot gnu.org
2023-04-08 14:40 ` law at gcc dot gnu.org
2023-04-26  6:57 ` [Bug tree-optimization/107823] [13/14 " rguenth at gcc dot gnu.org
2023-07-27  9:24 ` rguenth at gcc dot gnu.org
2023-11-24  3:42 ` pinskia at gcc dot gnu.org
2024-01-10 17:55 ` [Bug tree-optimization/107823] [13/14 Regression] Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) since r13-1934-g353fd1ec3df92f jamborm at gcc dot gnu.org
2024-01-11  0:44 ` pinskia at gcc dot gnu.org
2024-01-13  4:39 ` cvs-commit at gcc dot gnu.org
2024-01-13  4:40 ` pinskia 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).