public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable
@ 2023-04-18 15:07 theodort at inf dot ethz.ch
2023-04-19 7:58 ` [Bug tree-optimization/109546] [13/14 " rguenth at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-04-18 15:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
Bug ID: 109546
Summary: [13 Regression] Missed Dead Code Elimination when
using __builtin_unreachable
Product: gcc
Version: 13.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 input.c
void foo(void);
static int a, c;
static int *b = &a;
static int **d = &b;
void __assert_fail() __attribute__((__noreturn__));
int main() {
int *e = *d;
if (e == &a || e == &c);
else {
__assert_fail();
}
if (e == &a || e == &c);
else
foo();
}
both gcc 12 and trunk at -O3 generate the following code:
main:
movq b(%rip), %rax
cmpq $c, %rax
je .L2
cmpq $a, %rax
jne .L7
.L2:
xorl %eax, %eax
ret
.L7:
pushq %rax
xorl %eax, %eax
call __assert_fail
b:
.quad a
the call to foo is eliminated but the call to __assert_fail is missed, even
though
both if statement conditions are identical.
If add a __builtin_unreachable before the call to __assert_fail the opposite
happens:
void foo(void);
static int a, c;
static int *b = &a;
static int **d = &b;
void assert_fail() __attribute__((__noreturn__));
int main() {
int *e = *d;
if (e == &a || e == &c);
else {
__builtin_unreachable();
assert_fail();
}
if (e == &a || e == &c);
else
foo();
}
gcc-trunk -O3 generates:
main:
movq b(%rip), %rax
cmpq $c, %rax
je .L4
cmpq $a, %rax
je .L4
pushq %rax
call foo
xorl %eax, %eax
popq %rdx
ret
.L4:
xorl %eax, %eax
ret
b:
.quad a
the call to __assert_fail is now properly eliminated but now the call to foo is
missed.
This is a regression as gcc-12 generates:
main:
xorl %eax, %eax
ret
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
@ 2023-04-19 7:58 ` rguenth at gcc dot gnu.org
2023-04-20 13:03 ` [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca marxin at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-19 7:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[13 Regression] Missed |[13/14 Regression] Missed
|Dead Code Elimination when |Dead Code Elimination when
|using __builtin_unreachable |using __builtin_unreachable
Keywords| |missed-optimization
Target Milestone|--- |13.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
2023-04-19 7:58 ` [Bug tree-optimization/109546] [13/14 " rguenth at gcc dot gnu.org
@ 2023-04-20 13:03 ` marxin at gcc dot gnu.org
2023-04-21 18:52 ` amacleod at redhat dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-04-20 13:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amacleod at redhat dot com,
| |marxin at gcc dot gnu.org
Summary|[13/14 Regression] Missed |[13/14 Regression] Missed
|Dead Code Elimination when |Dead Code Elimination when
|using __builtin_unreachable |using __builtin_unreachable
| |since
| |r13-3596-ge7310e24b1c0ca
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r13-3596-ge7310e24b1c0ca.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
2023-04-19 7:58 ` [Bug tree-optimization/109546] [13/14 " rguenth at gcc dot gnu.org
2023-04-20 13:03 ` [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca marxin at gcc dot gnu.org
@ 2023-04-21 18:52 ` amacleod at redhat dot com
2023-04-21 18:55 ` amacleod at redhat dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: amacleod at redhat dot com @ 2023-04-21 18:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
--- Comment #2 from Andrew Macleod <amacleod at redhat dot com> ---
*** Bug 109588 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
` (2 preceding siblings ...)
2023-04-21 18:52 ` amacleod at redhat dot com
@ 2023-04-21 18:55 ` amacleod at redhat dot com
2023-04-21 19:18 ` amacleod at redhat dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: amacleod at redhat dot com @ 2023-04-21 18:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
Patch in testing.
when deciding to fold condition of builtin_unreachable, VRP is failing to
recognize that given
if (ptr == &x)
__builtin_unreachable ()
&x is not a representable range, and thus should not be eliminated early even
though it satisfies the other criteria.
it just sees it as a symbolic value == CONSTANT and thinks its smart enough
when it isn't.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
` (3 preceding siblings ...)
2023-04-21 18:55 ` amacleod at redhat dot com
@ 2023-04-21 19:18 ` amacleod at redhat dot com
2023-04-21 20:34 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: amacleod at redhat dot com @ 2023-04-21 19:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
And I think the first part of this is a duplicate of another PR from GCC12
time (I dont know which one) whereby we are not making staticly initialized
values available in main(). so VRP never sees that d == &b, and can do nothing
with the first condition, thus leaving the call to __assert_fail.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
` (4 preceding siblings ...)
2023-04-21 19:18 ` amacleod at redhat dot com
@ 2023-04-21 20:34 ` cvs-commit at gcc dot gnu.org
2023-04-26 6:58 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-21 20:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:
https://gcc.gnu.org/g:f828503eeb79ad1f1ada6db7deccc5abcc2f3ca3
commit r14-160-gf828503eeb79ad1f1ada6db7deccc5abcc2f3ca3
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Fri Apr 21 15:03:43 2023 -0400
Do not fold ADDR_EXPR conditions leading to builtin_unreachable early.
Ranges can not represent &var globally yet, so we cannot fold these
expressions early or we lose the __builtin_unreachable information.
PR tree-optimization/109546
gcc/
* tree-vrp.cc (remove_unreachable::remove_and_update_globals): Do
not fold conditions with ADDR_EXPR early.
gcc/testsuite/
* gcc.dg/pr109546.c: New.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
` (5 preceding siblings ...)
2023-04-21 20:34 ` cvs-commit at gcc dot gnu.org
@ 2023-04-26 6:58 ` rguenth at gcc dot gnu.org
2023-07-27 9:25 ` rguenth at gcc dot gnu.org
2023-09-17 4:10 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26 6:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.0 |13.2
--- Comment #6 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] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
` (6 preceding siblings ...)
2023-04-26 6:58 ` rguenth at gcc dot gnu.org
@ 2023-07-27 9:25 ` rguenth at gcc dot gnu.org
2023-09-17 4:10 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27 9:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.2 |13.3
--- Comment #7 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] 10+ messages in thread
* [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
` (7 preceding siblings ...)
2023-07-27 9:25 ` rguenth at gcc dot gnu.org
@ 2023-09-17 4:10 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-17 4:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109546
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|13.3 |14.0
Status|UNCONFIRMED |RESOLVED
--- 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:[~2023-09-17 4:10 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 15:07 [Bug tree-optimization/109546] New: [13 Regression] Missed Dead Code Elimination when using __builtin_unreachable theodort at inf dot ethz.ch
2023-04-19 7:58 ` [Bug tree-optimization/109546] [13/14 " rguenth at gcc dot gnu.org
2023-04-20 13:03 ` [Bug tree-optimization/109546] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-3596-ge7310e24b1c0ca marxin at gcc dot gnu.org
2023-04-21 18:52 ` amacleod at redhat dot com
2023-04-21 18:55 ` amacleod at redhat dot com
2023-04-21 19:18 ` amacleod at redhat dot com
2023-04-21 20:34 ` cvs-commit at gcc dot gnu.org
2023-04-26 6:58 ` rguenth at gcc dot gnu.org
2023-07-27 9:25 ` rguenth at gcc dot gnu.org
2023-09-17 4:10 ` 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).