public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
@ 2021-11-16 18:31 theodort at inf dot ethz.ch
  2021-11-16 20:51 ` [Bug tree-optimization/103281] [9/12 " pinskia at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: theodort at inf dot ethz.ch @ 2021-11-16 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103281
           Summary: [12 Regression] Dead Code Elimination Regression at
                    -O3 (trunk vs 11.2.0)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theodort at inf dot ethz.ch
  Target Milestone: ---

cat case.c
void foo(void);

static unsigned b;

int main() {
  for (; b < 3; b++) {
    char c = b;
    char a = c ? c : c << 1;
    if (!(a < 1 ^ b))
      foo();
  }
}

trunk cannot eliminate the call to foo but 11.2.0 can:

gcc-11.2.0 -O3 -S -o /dev/stdout case.c
main:
.LFB0:
        .cfi_startproc
        movl    b(%rip), %eax
        cmpl    $2, %eax
        ja      .L6
        testl   %eax, %eax
        movl    $1, %edx
        cmove   %edx, %eax
.L8:
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $2, %eax
        je      .L8
.L6:
        xorl    %eax, %eax
        ret
        .cfi_endproc


gcc-trunk -O3 -S -o /dev/stdout case.c
main:
.LFB0:
        .cfi_startproc
        movl    b(%rip), %eax
        cmpl    $2, %eax
        ja      .L13
        .p2align 4,,10
        .p2align 3
.L12:
        xorl    %edx, %edx
        testb   %al, %al
        setle   %dl
        cmpl    %eax, %edx
        je      .L16
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $3, %eax
        jne     .L12
.L13:
        xorl    %eax, %eax
        ret
        .p2align 4,,10
        .p2align 3
.L16:
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
.L14:
        call    foo
        movl    b(%rip), %eax
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $2, %eax
        ja      .L7
.L2:
        xorl    %edx, %edx
        testb   %al, %al
        setle   %dl
        cmpl    %eax, %edx
        je      .L14
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $3, %eax
        jne     .L2
.L7:
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc


gcc-trunk -v
Using built-in specs.
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211116 (experimental) (GCC)

Started with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7d6979197274a662da7bdc564314afe8415865c1

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

* [Bug tree-optimization/103281] [9/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
@ 2021-11-16 20:51 ` pinskia at gcc dot gnu.org
  2021-11-16 20:52 ` [Bug tree-optimization/103281] [9/10/12 " pinskia at gcc dot gnu.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 20:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
      Known to fail|                            |10.1.0, 12.0, 4.7.1, 4.8.1,
                   |                            |9.1.0
            Summary|[12 Regression] Dead Code   |[9/12 Regression] Dead Code
                   |Elimination Regression at   |Elimination Regression at
                   |-O3 (trunk vs 11.2.0)       |-O3 (trunk vs 11.2.0)
   Last reconfirmed|                            |2021-11-16
      Known to work|                            |11.1.0, 4.9.0, 4.9.4,
                   |                            |5.1.0, 6.1.0, 7.1.0, 8.1.0
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The only thing which PHIOPT does is change:
  if (c_15 == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :

  <bb 5> :
  # iftmp.1_10 = PHI <0(4), c_15(3)>

to be:
iftmp.1_10 = c_15;

This is a missed VRP:
  # RANGE [0, 2] NONZERO 3
  c_9 = (charD.10) b.4_5;
  _1 = c_9 <= 0;
  # RANGE [0, 1] NONZERO 1
  _2 = (unsigned intD.14) _1;
  if (_2 == b.4_5)

_1/_2 is true/1 only when c_9 is 0 and only when b.4_5 is 0.

----- CUT -----


We should be able to optimize:
void foo(void);

static unsigned b;

int main() {
  for (; b < 3; b++) {
    char c = b;
    char a = c;
    if (!((a < 1) ^ b))
      foo();
  }
}
Too.

We also miss:
void foo(void);

static unsigned b;

int main() {
  for (; b < 3; b++) {
    if (!((b < 1) ^ b))
      foo();
  }
}

  _1 = b.2_6 == 0;
  _2 = (unsigned int) _1;
  if (_2 == b.2_6)

I want to say we should defer this until after GCC 12 because this was only
being optimized on accident.  phiopt1

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

* [Bug tree-optimization/103281] [9/10/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
  2021-11-16 20:51 ` [Bug tree-optimization/103281] [9/12 " pinskia at gcc dot gnu.org
@ 2021-11-16 20:52 ` pinskia at gcc dot gnu.org
  2021-11-16 21:03 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/12 Regression] Dead Code |[9/10/12 Regression] Dead
                   |Elimination Regression at   |Code Elimination Regression
                   |-O3 (trunk vs 11.2.0)       |at -O3 (trunk vs 11.2.0)

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> I want to say we should defer this until after GCC 12 because this was only
> being optimized on accident.  phiopt1

As you can see by this used to work between 4.9-8.0 and then regressed in GCC 9
and 10.

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

* [Bug tree-optimization/103281] [9/10/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
  2021-11-16 20:51 ` [Bug tree-optimization/103281] [9/12 " pinskia at gcc dot gnu.org
  2021-11-16 20:52 ` [Bug tree-optimization/103281] [9/10/12 " pinskia at gcc dot gnu.org
@ 2021-11-16 21:03 ` pinskia at gcc dot gnu.org
  2021-11-16 21:16 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Would be interesting to know what "fixed" it for 11 and what broke it for 9
really.

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

* [Bug tree-optimization/103281] [9/10/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2021-11-16 21:03 ` pinskia at gcc dot gnu.org
@ 2021-11-16 21:16 ` pinskia at gcc dot gnu.org
  2021-11-18 10:31 ` marxin at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> The only thing which PHIOPT does is change:
>   if (c_15 == 0)
>     goto <bb 4>; [INV]
>   else
>     goto <bb 5>; [INV]
> 
>   <bb 4> :
> 
>   <bb 5> :
>   # iftmp.1_10 = PHI <0(4), c_15(3)>
> 
> to be:
> iftmp.1_10 = c_15;
> 
> This is a missed VRP:
>   # RANGE [0, 2] NONZERO 3
>   c_9 = (charD.10) b.4_5;
>   _1 = c_9 <= 0;
>   # RANGE [0, 1] NONZERO 1
>   _2 = (unsigned intD.14) _1;
>   if (_2 == b.4_5)

Note it just happens that iftmp.1_10 case of being 0 is the only that matters
to be "peeled" off and special cased.

Plus it just happens:
    char a = c ? c : c << 1;

Is hiding the relationship between a and c.

GCC does optimize if we change the loop to:
b >= 1 && b < 4

What we need to realize is that 0 needs to "peeled" off and tried seperately
with the range. that is the following two ranges need to be done seperately for
b.4_5:
[0, 0] [1, 2]
But how do GCC decides that is "hard".
we know the range of _1 to be [0,1] so we need to figure out the ranges of c_9
which cause 0 and which one causes 1.  This is not just a forward looking
alogrothim but need to look back really. It can be very computational
instensive too.

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

* [Bug tree-optimization/103281] [9/10/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2021-11-16 21:16 ` pinskia at gcc dot gnu.org
@ 2021-11-18 10:31 ` marxin at gcc dot gnu.org
  2022-01-18 14:28 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-18 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
For GCC 9, it started failing with r9-3923-g85eaf6c6a3678d7e.

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

* [Bug tree-optimization/103281] [9/10/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2021-11-18 10:31 ` marxin at gcc dot gnu.org
@ 2022-01-18 14:28 ` rguenth at gcc dot gnu.org
  2022-05-27  9:46 ` [Bug tree-optimization/103281] [10/12/13 " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-18 14:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
   Target Milestone|12.0                        |9.5

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

* [Bug tree-optimization/103281] [10/12/13 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2022-01-18 14:28 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:46 ` rguenth at gcc dot gnu.org
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug tree-optimization/103281] [10/12/13 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (6 preceding siblings ...)
  2022-05-27  9:46 ` [Bug tree-optimization/103281] [10/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
  2023-05-01 23:49 ` [Bug tree-optimization/103281] [10/12/13/14 " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug tree-optimization/103281] [10/12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (7 preceding siblings ...)
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2023-05-01 23:49 ` pinskia at gcc dot gnu.org
  2023-08-07  5:47 ` [Bug tree-optimization/103281] [12/13/14 " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-01 23:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm:
  # RANGE [irange] char [0, 2] NONZERO 0x3
  c_9 = (charD.7) b.4_5;
  _1 = c_9 <= 0;



Should _1 be replaced with c_9 == 0 which then can be simplified to b.4_5 == 0
That is PR 28794 I think.

And then after that we get:
b.4_5 == (unsigned int)(b.4_5 == 0)

Which should be optimized down to false though we don't either.
unsigned f(unsigned t)
{
        unsigned a = t == 0;
        return t == a;
}

The general CST cases (I hope I did these correctly):
a == (a == CST) ->
CST == 0 -> false
CST == 1 -> a == 1 | a == 0
others   -> a == 0

a != (a == CST) ->
CST == 0: false
CST == 1: a != 0 || a != 1
others  : a != 0

a != (a != CST) ->
CST == 0: a == 1 | a == 0
CST == 1: true
others  : a != 1

a == (a != CST) ->
CST == 0: a == 1 | a == 0
CST == 1: false
others  : a == 1

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

* [Bug tree-optimization/103281] [12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (8 preceding siblings ...)
  2023-05-01 23:49 ` [Bug tree-optimization/103281] [10/12/13/14 " pinskia at gcc dot gnu.org
@ 2023-08-07  5:47 ` pinskia at gcc dot gnu.org
  2023-08-07  6:34 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07  5:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |110293

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> We should be able to optimize:

This second testcase in comment #1 is now optimized since
r14-2501-g285c9d042e90a7425b376 .

Likewise the testcase in comment #8.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110293
[Bug 110293] Some `A CMP (A NEEQ 0)` is not simplified in some cases

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

* [Bug tree-optimization/103281] [12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (9 preceding siblings ...)
  2023-08-07  5:47 ` [Bug tree-optimization/103281] [12/13/14 " pinskia at gcc dot gnu.org
@ 2023-08-07  6:34 ` pinskia at gcc dot gnu.org
  2023-08-07  6:34 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07  6:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |28794

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch for PR 28794 fixes this too.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794
[Bug 28794] missed optimization with non-COND_EXPR and vrp and comparisions

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

* [Bug tree-optimization/103281] [12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (10 preceding siblings ...)
  2023-08-07  6:34 ` pinskia at gcc dot gnu.org
@ 2023-08-07  6:34 ` pinskia at gcc dot gnu.org
  2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07  6:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug tree-optimization/103281] [12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (11 preceding siblings ...)
  2023-08-07  6:34 ` pinskia at gcc dot gnu.org
@ 2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org
  2023-08-08 15:43 ` pinskia at gcc dot gnu.org
  2023-08-08 15:46 ` pinskia at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-08 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS 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:aadc5c07feb0ab08729ab25d0d896b55860ad9e6

commit r14-3084-gaadc5c07feb0ab08729ab25d0d896b55860ad9e6
Author: Andrew Pinski <apinski@marvell.com>
Date:   Mon Aug 7 00:05:21 2023 -0700

    VR-VALUES [PR28794]: optimize compare assignments also

    This patch fixes the oldish (2006) bug where VRP was not
    optimizing the comparison for assignments while handling
    them for GIMPLE_COND only.
    It just happens to also solves PR 103281 due to allowing
    to optimize `c < 1` to `c == 0` and then we get
    `(c == 0) == c` (which was handled by r14-2501-g285c9d04).

    OK? Bootstrapped and tested on x86_64-linux-gnu with no
    regressions.

            PR tree-optimization/103281
            PR tree-optimization/28794

    gcc/ChangeLog:

            * vr-values.cc
(simplify_using_ranges::simplify_cond_using_ranges_1): Split out
            majority to ...
            (simplify_using_ranges::simplify_compare_using_ranges_1): Here.
            (simplify_using_ranges::simplify_casted_cond): Rename to ...
            (simplify_using_ranges::simplify_casted_compare): This
            and change arguments to take op0 and op1.
            (simplify_using_ranges::simplify_compare_assign_using_ranges_1):
New method.
            (simplify_using_ranges::simplify): For tcc_comparison assignments
call
            simplify_compare_assign_using_ranges_1.
            * vr-values.h (simplify_using_ranges): Add
            new methods, simplify_compare_using_ranges_1 and
simplify_compare_assign_using_ranges_1.
            Rename simplify_casted_cond and simplify_casted_compare and
            update argument types.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr103281-1.c: New test.
            * gcc.dg/tree-ssa/vrp-compare-1.c: New test.

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

* [Bug tree-optimization/103281] [12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (12 preceding siblings ...)
  2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org
@ 2023-08-08 15:43 ` pinskia at gcc dot gnu.org
  2023-08-08 15:46 ` pinskia at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-08 15:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103281
Bug 103281 depends on bug 28794, which changed state.

Bug 28794 Summary: missed optimization with non-COND_EXPR and vrp and comparisions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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

* [Bug tree-optimization/103281] [12/13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
  2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
                   ` (13 preceding siblings ...)
  2023-08-08 15:43 ` pinskia at gcc dot gnu.org
@ 2023-08-08 15:46 ` pinskia at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-08 15:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed for GCC 14 and since this is a missed optimization with generated code,
it is less likely to show up in real code so closing as fixed.

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

end of thread, other threads:[~2023-08-08 15:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-11-16 20:51 ` [Bug tree-optimization/103281] [9/12 " pinskia at gcc dot gnu.org
2021-11-16 20:52 ` [Bug tree-optimization/103281] [9/10/12 " pinskia at gcc dot gnu.org
2021-11-16 21:03 ` pinskia at gcc dot gnu.org
2021-11-16 21:16 ` pinskia at gcc dot gnu.org
2021-11-18 10:31 ` marxin at gcc dot gnu.org
2022-01-18 14:28 ` rguenth at gcc dot gnu.org
2022-05-27  9:46 ` [Bug tree-optimization/103281] [10/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-05-01 23:49 ` [Bug tree-optimization/103281] [10/12/13/14 " pinskia at gcc dot gnu.org
2023-08-07  5:47 ` [Bug tree-optimization/103281] [12/13/14 " pinskia at gcc dot gnu.org
2023-08-07  6:34 ` pinskia at gcc dot gnu.org
2023-08-07  6:34 ` pinskia at gcc dot gnu.org
2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org
2023-08-08 15:43 ` pinskia at gcc dot gnu.org
2023-08-08 15:46 ` 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).