public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
@ 2023-08-08 9:11 scherrer.sv at gmail dot com
2023-08-08 9:51 ` [Bug tree-optimization/110941] " rguenth at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: scherrer.sv at gmail dot com @ 2023-08-08 9:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
Bug ID: 110941
Summary: [14 Regression] Dead Code Elimination Regression at
-O3 since r14-2379-gc496d15954c
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 a;
void foo(void);
void bar349_(void);
void bar363_(void);
void bar275_(void);
int main() {
{
{
short b = 26;
for (; b >= 1; b = b - 4) {
if (b >= 2 && b <= 26)
bar275_();
if (a)
bar363_();
if (a)
bar349_();
int c = b;
if (!(c >= 2 && c <= 26))
foo();
}
}
a = 0;
}
}
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:
.LFB0:
.cfi_startproc
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl $24, %ebx
.p2align 4,,10
.p2align 3
.L8:
cmpw $24, %bx
jbe .L2
movl a(%rip), %edx
testl %edx, %edx
jne .L3
.L7:
call foo
xorl %eax, %eax
popq %rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
movl $0, a(%rip)
ret
.p2align 4,,10
.p2align 3
.L3:
.cfi_restore_state
call bar363_
movl a(%rip), %eax
testl %eax, %eax
je .L7
call bar349_
jmp .L7
.L2:
call bar275_
cmpl $0, a(%rip)
jne .L15
.p2align 4,,10
.p2align 3
.L6:
subl $4, %ebx
cmpl $-4, %ebx
jne .L8
movl $0, a(%rip)
xorl %eax, %eax
popq %rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L15:
.cfi_restore_state
call bar363_
cmpl $0, a(%rip)
je .L6
call bar349_
cmpl $24, %ebx
jbe .L6
jmp .L7
---------- END OUTPUT ---------
-----------------------------------------------------------------------
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB0:
.cfi_startproc
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl $24, %ebx
.L10:
cmpw $24, %bx
jbe .L2
movl a(%rip), %edx
testl %edx, %edx
jne .L17
.L3:
movl $0, a(%rip)
xorl %eax, %eax
popq %rbx
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L17:
.cfi_restore_state
call bar363_
movl a(%rip), %eax
testl %eax, %eax
jne .L4
.L15:
subl $4, %ebx
jmp .L10
.p2align 4,,10
.p2align 3
.L4:
call bar349_
jmp .L15
.L2:
call bar275_
cmpl $0, a(%rip)
jne .L18
.p2align 4,,10
.p2align 3
.L9:
subl $4, %ebx
cmpw $-4, %bx
jne .L10
jmp .L3
.L18:
call bar363_
cmpl $0, a(%rip)
je .L9
call bar349_
jmp .L9
---------- END OUTPUT ---------
-----------------------------------------------------------------------
Bisects to r14-2379-gc496d15954c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
@ 2023-08-08 9:51 ` rguenth at gcc dot gnu.org
2023-08-08 16:35 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ 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=110941
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
2023-08-08 9:51 ` [Bug tree-optimization/110941] " rguenth at gcc dot gnu.org
@ 2023-08-08 16:35 ` pinskia at gcc dot gnu.org
2023-09-16 7:46 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-08 16:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-08-08
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
# RANGE [irange] unsigned int [0, 16][20, 20][24, 24][65532,
4294901776][4294967293, +INF] MASK 0xfffffffc VALUE 0x0
# ivtmp.18_37 = PHI <ivtmp.18_38(8), 24(2)>
# RANGE [irange] unsigned short [0, +INF] MASK 0xfffc VALUE 0xfffc
_21 = (unsigned short) ivtmp.18_37;
if (_21 <= 24)
Confirmed. The range for _21 is way to conserative.
It should have been: `[0, 16][20, 20][24, 24]`.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
2023-08-08 9:51 ` [Bug tree-optimization/110941] " rguenth at gcc dot gnu.org
2023-08-08 16:35 ` pinskia at gcc dot gnu.org
@ 2023-09-16 7:46 ` pinskia at gcc dot gnu.org
2023-11-24 4:28 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 7:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC 13:
Global Exported: _6 = [irange] unsigned int [0, 24] NONZERO 0x1e
trunk:
Global Exported: _6 = [irange] unsigned int [0, 24][+INF, +INF] MASK 0x1c VALUE
0x0
And then:
Folding predicate _6 > 24 to 0
does not happen.
But what is interesting is with
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629128.html ,
We get:
```
Simplified relational if (_6 > 24)
into if (_6 == 4294967295)
Folded into: if (_6 == 4294967295)
```
And then during cfgcleanup the match pattern:
/* X == C (or X & Z == Y | C) is impossible if ~nonzero(X) & C != 0. */
Hits which is totally funny because that means the range and nonzero
information are out of sync ...
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
` (2 preceding siblings ...)
2023-09-16 7:46 ` pinskia at gcc dot gnu.org
@ 2023-11-24 4:28 ` pinskia at gcc dot gnu.org
2024-01-10 14:46 ` jamborm at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-24 4:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
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> ---
This seems to be fixed now. We are able to optimize out the call to foo even in
evrp now too.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
` (3 preceding siblings ...)
2023-11-24 4:28 ` pinskia at gcc dot gnu.org
@ 2024-01-10 14:46 ` jamborm at gcc dot gnu.org
2024-01-11 1:08 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-10 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #4 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] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
` (4 preceding siblings ...)
2024-01-10 14:46 ` jamborm at gcc dot gnu.org
@ 2024-01-11 1:08 ` pinskia at gcc dot gnu.org
2024-01-13 4:39 ` cvs-commit at gcc dot gnu.org
2024-01-13 4:41 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-11 1:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
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 #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Will commit a testcase for this.
r14-5109-ga291237b628f41 is definitely the fix for this based on my analysis in
comment #2:
> GCC 13:
> Global Exported: _6 = [irange] unsigned int [0, 24] NONZERO 0x1e
> trunk:
> Global Exported: _6 = [irange] unsigned int [0, 24][+INF, +INF] MASK 0x1c VALUE 0x0
The removal of `[+INF, +INF]` here fixes the issue earlier
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
` (5 preceding siblings ...)
2024-01-11 1:08 ` pinskia at gcc dot gnu.org
@ 2024-01-13 4:39 ` cvs-commit at gcc dot gnu.org
2024-01-13 4:41 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ 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=110941
--- Comment #6 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] 9+ messages in thread
* [Bug tree-optimization/110941] [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
` (6 preceding siblings ...)
2024-01-13 4:39 ` cvs-commit at gcc dot gnu.org
@ 2024-01-13 4:41 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-13 4:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-01-13 4:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-08 9:11 [Bug tree-optimization/110941] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c scherrer.sv at gmail dot com
2023-08-08 9:51 ` [Bug tree-optimization/110941] " rguenth at gcc dot gnu.org
2023-08-08 16:35 ` pinskia at gcc dot gnu.org
2023-09-16 7:46 ` pinskia at gcc dot gnu.org
2023-11-24 4:28 ` pinskia at gcc dot gnu.org
2024-01-10 14:46 ` jamborm at gcc dot gnu.org
2024-01-11 1:08 ` pinskia at gcc dot gnu.org
2024-01-13 4:39 ` cvs-commit at gcc dot gnu.org
2024-01-13 4:41 ` 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).