public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
@ 2023-07-21 13:59 theodort at inf dot ethz.ch
2023-07-21 21:07 ` [Bug tree-optimization/110768] " pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-07-21 13:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
Bug ID: 110768
Summary: [14 Regression] Dead Code Elimination Regression since
r14-2623-gc11a3aedec2
Product: gcc
Version: 14.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: ---
https://godbolt.org/z/GsTMz1G9c
Given the following code:
void foo(void);
static int a, b;
int main() {
{
short c = 45127;
char d;
b = 0;
for (; b <= 3; b++) {
if (b) continue;
d = 0;
for (; d <= 3; d++) {
if (!(((c) >= -20409) && ((c) <= 1))) {
__builtin_unreachable();
}
if (~(0 == a) & 1) return b;
c = 0;
for (; c <= 0; c++) a = 3;
}
}
foo();
}
}
gcc-trunk -Os does not eliminate the call to foo:
main:
xorl %r9d, %r9d
movl a(%rip), %eax
xorl %edx, %edx
xorl %esi, %esi
movl %r9d, b(%rip)
xorl %ecx, %ecx
.L2:
cmpl $4, %edx
je .L31
testl %edx, %edx
jne .L3
testl %eax, %eax
je .L4
.L24:
testb %sil, %sil
je .L5
xorl %r8d, %r8d
movl %r8d, b(%rip)
.L5:
testb %cl, %cl
je .L27
movl %eax, a(%rip)
jmp .L27
.L4:
movl $3, %eax
movb $1, %cl
jmp .L24
.L3:
incl %edx
movb $1, %sil
jmp .L2
.L31:
pushq %rdi
testb %sil, %sil
je .L9
movl $4, b(%rip)
.L9:
testb %cl, %cl
je .L10
movl %eax, a(%rip)
.L10:
call foo
xorl %eax, %eax
popq %rdx
ret
.L27:
xorl %eax, %eax
ret
gcc-13.1.0 -Os eliminates the call to foo:
main:
xorl %eax, %eax
cmpl $0, a(%rip)
movl %eax, b(%rip)
jne .L2
movl $3, a(%rip)
.L2:
xorl %eax, %eax
ret
Bisects to r14-2623-gc11a3aedec2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
@ 2023-07-21 21:07 ` pinskia at gcc dot gnu.org
2023-07-21 22:54 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-21 21:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
2023-07-21 21:07 ` [Bug tree-optimization/110768] " pinskia at gcc dot gnu.org
@ 2023-07-21 22:54 ` pinskia at gcc dot gnu.org
2023-08-25 23:34 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-21 22:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
3) optimize_size logic is now different. Originally we started duplicating
iff the first conditional was known to be true by ranger query, but then
we used same limits as for -O2.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
2023-07-21 21:07 ` [Bug tree-optimization/110768] " pinskia at gcc dot gnu.org
2023-07-21 22:54 ` pinskia at gcc dot gnu.org
@ 2023-08-25 23:34 ` pinskia at gcc dot gnu.org
2024-01-10 14:52 ` jamborm at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-25 23:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks to be fixed now.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
` (2 preceding siblings ...)
2023-08-25 23:34 ` pinskia at gcc dot gnu.org
@ 2024-01-10 14:52 ` jamborm at gcc dot gnu.org
2024-01-11 1:01 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-01-10 14:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #3 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] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
` (3 preceding siblings ...)
2024-01-10 14:52 ` jamborm at gcc dot gnu.org
@ 2024-01-11 1:01 ` pinskia at gcc dot gnu.org
2024-01-13 4:01 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-11 1:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2024-01-11
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Will commit the testcase and close it as fixed.
The range improvements allows loop ch to do a better job ...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
` (4 preceding siblings ...)
2024-01-11 1:01 ` pinskia at gcc dot gnu.org
@ 2024-01-13 4:01 ` pinskia at gcc dot gnu.org
2024-01-13 4:39 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-13 4:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110768
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the main difference after this patch:
Global Exported: c_11 = [irange] short int [-20409, -20409][1, 1] MASK 0xb046
VALUE 0xb047
vs before:
Global Exported: c_11 = [irange] short int [-INF, +INF] NONZERO 0xb047
That is we figure out c_11 will only either be -20409 [(short)45127] or 1 now.
That allows to get rid of if statement that leads to unreachable.
Which then allows unrolling to happen as the estimate for that loop is less.
Note the following testcase (which is fixed also on the trunk) was failing in
GCC 13:
```
void foo(void);
static int a, b;
int main() {
{
short c = 45127;
int d;
b = 0;
for (; b <= 3; b++) {
if (b) continue;
d = 0;
for (; d <= 127; d++) {
if (!(((c) >= -20409) && ((c) <= 1))) {
__builtin_unreachable();
}
if (~(0 == a) & 1) return b;
c = 0;
for (; c <= 0; c++) a = 3;
}
}
foo();
}
}
```
The difference between this one and the original testcase is the # of
iterations of the loop. The same thing applies here; though I don't know what
caused the regression between GCC 12 and 13 for this one.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
` (5 preceding siblings ...)
2024-01-13 4:01 ` 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
2024-01-13 4:41 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ 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=110768
--- 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] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
` (6 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
2024-01-13 4:41 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ 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=110768
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/110768] [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
` (7 preceding siblings ...)
2024-01-13 4:40 ` pinskia at gcc dot gnu.org
@ 2024-01-13 4:41 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ 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=110768
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-01-13 4:41 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 13:59 [Bug tree-optimization/110768] New: [14 Regression] Dead Code Elimination Regression since r14-2623-gc11a3aedec2 theodort at inf dot ethz.ch
2023-07-21 21:07 ` [Bug tree-optimization/110768] " pinskia at gcc dot gnu.org
2023-07-21 22:54 ` pinskia at gcc dot gnu.org
2023-08-25 23:34 ` pinskia at gcc dot gnu.org
2024-01-10 14:52 ` jamborm at gcc dot gnu.org
2024-01-11 1:01 ` pinskia at gcc dot gnu.org
2024-01-13 4:01 ` 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
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).