public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911
@ 2023-08-02 12:34 scherrer.sv at gmail dot com
  2023-08-02 13:02 ` [Bug tree-optimization/110873] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: scherrer.sv at gmail dot com @ 2023-08-02 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110873
           Summary: [14 Regression] Dead Code Elimination Regression at
                    -O2 since r14-376-g47a76439911
           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;
static short c;
static char d;
static int *e = &b;
void foo(void);  
void bar110_(void);
static char(a)(char f, char g) { return f + g; }
int main() {
    *e = 3;
    unsigned char h;
    c = 0;
i:
    if (!b)
        foo();
    h = -25;
    for (; h >= 7; h = a(h, 6))
        for (; d; d--)
            ;
    if (!(h >= 5))
        bar110_();
    if (c)
        goto i;
}
-----------------------------------------------------------------------
gcc-68c3aa7510b (trunk) -O2 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O2 can
-----------------------------------------------------------------------
gcc-68c3aa7510b2f45f44379ecd77e97c88780a84ed -O2 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB1:
        .cfi_startproc
        movl    $3, b(%rip)
        xorl    %esi, %esi
        movw    %si, c(%rip)
.L11:
        cmpb    $0, d(%rip)
        je      .L13
        movb    $0, d(%rip)
.L13:
        cmpw    $0, c(%rip)
        je      .L15
        movl    b(%rip), %eax
        testl   %eax, %eax
        jne     .L11
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
.L6:
        call    foo
.L2:
        cmpb    $0, d(%rip)
        je      .L4
        movb    $0, d(%rip)
.L4:
        cmpw    $0, c(%rip)
        je      .L5
        movl    b(%rip), %ecx
        testl   %ecx, %ecx
        jne     .L2
        jmp     .L6
.L15:
        .cfi_def_cfa_offset 8
        xorl    %eax, %eax
        ret
.L5:
        .cfi_def_cfa_offset 16
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------

-----------------------------------------------------------------------
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O2 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB1:
        .cfi_startproc
        movl    $3, b(%rip)
        xorl    %eax, %eax
        cmpb    $0, d(%rip)
        movw    %ax, c(%rip)
        je      .L3
        movb    $0, d(%rip)
.L3:
        xorl    %eax, %eax
        ret
---------- END OUTPUT ---------

-----------------------------------------------------------------------
Bisects to r14-376-g47a76439911

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

* [Bug tree-optimization/110873] [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911
  2023-08-02 12:34 [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911 scherrer.sv at gmail dot com
@ 2023-08-02 13:02 ` rguenth at gcc dot gnu.org
  2023-08-03  2:59 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-02 13:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
   Target Milestone|---                         |14.0

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

* [Bug tree-optimization/110873] [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911
  2023-08-02 12:34 [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911 scherrer.sv at gmail dot com
  2023-08-02 13:02 ` [Bug tree-optimization/110873] " rguenth at gcc dot gnu.org
@ 2023-08-03  2:59 ` pinskia at gcc dot gnu.org
  2023-08-03  3:00 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-03  2:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC 13 had:
```
 Registering value_relation (h_29 == h_13) (bb10) at h_29 = PHI <h_13(9)>
   Loops range found for h_29: [irange] unsigned char [5, 5] NONZERO 0x5 and
calculated range :[irange] unsigned char [0, 5] NONZERO 0x7
Global Exported: h_29 = [irange] unsigned char [5, 5] NONZERO 0x5
Folding PHI node: h_29 = PHI <h_13(9)>
Queued PHI for removal.  Folds to: 5
Folding statement: if (h_29 <= 4)
gimple_simplified to if (0 != 0)
gimple_simplified to if (0 != 0)
Folded into: if (0 != 0)
``
While trunk does:
```
redicate evaluates to: DON'T KNOW
Not folded
 Registering value_relation (h_29 == h_13) (bb10) at h_29 = PHI <h_13(9)>
Global Exported: h_29 = [irange] unsigned char [0, 5] MASK 0xfe VALUE 0xe7
Folding PHI node: h_29 = PHI <h_13(9)>
No folding possible
Folding statement: if (h_29 <= 4)

Visiting conditional with predicate: if (h_29 <= 4)

With known ranges
        h_29: [irange] unsigned char [0, 5] MASK 0xfe VALUE 0xe7

Predicate evaluates to: DON'T KNOW
Simplified relational if (h_29 <= 4)
 into if (h_29 != 5)

Folded into: if (h_29 != 5)
```
Which totally misses that h_29 was just 5.

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

* [Bug tree-optimization/110873] [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911
  2023-08-02 12:34 [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911 scherrer.sv at gmail dot com
  2023-08-02 13:02 ` [Bug tree-optimization/110873] " rguenth at gcc dot gnu.org
  2023-08-03  2:59 ` pinskia at gcc dot gnu.org
@ 2023-08-03  3:00 ` pinskia at gcc dot gnu.org
  2024-03-07 23:27 ` law at gcc dot gnu.org
  2024-05-07  7:41 ` [Bug tree-optimization/110873] [14/15 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-03  3:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there are other missed optimizations later on too even in GCC 13.

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

* [Bug tree-optimization/110873] [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911
  2023-08-02 12:34 [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911 scherrer.sv at gmail dot com
                   ` (2 preceding siblings ...)
  2023-08-03  3:00 ` pinskia at gcc dot gnu.org
@ 2024-03-07 23:27 ` law at gcc dot gnu.org
  2024-05-07  7:41 ` [Bug tree-optimization/110873] [14/15 " rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 23:27 UTC (permalink / raw)
  To: gcc-bugs

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

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] 6+ messages in thread

* [Bug tree-optimization/110873] [14/15 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911
  2023-08-02 12:34 [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911 scherrer.sv at gmail dot com
                   ` (3 preceding siblings ...)
  2024-03-07 23:27 ` law at gcc dot gnu.org
@ 2024-05-07  7:41 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2024-05-07  7:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 12:34 [Bug tree-optimization/110873] New: [14 Regression] Dead Code Elimination Regression at -O2 since r14-376-g47a76439911 scherrer.sv at gmail dot com
2023-08-02 13:02 ` [Bug tree-optimization/110873] " rguenth at gcc dot gnu.org
2023-08-03  2:59 ` pinskia at gcc dot gnu.org
2023-08-03  3:00 ` pinskia at gcc dot gnu.org
2024-03-07 23:27 ` law at gcc dot gnu.org
2024-05-07  7:41 ` [Bug tree-optimization/110873] [14/15 " rguenth 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).