public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109601] New: Useless branch not eliminated when writing to a union
@ 2023-04-23 18:26 67 at mniip dot com
2023-04-23 18:48 ` [Bug rtl-optimization/109601] " pinskia at gcc dot gnu.org
2023-04-23 18:58 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: 67 at mniip dot com @ 2023-04-23 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109601
Bug ID: 109601
Summary: Useless branch not eliminated when writing to a union
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: 67 at mniip dot com
Target Milestone: ---
Created attachment 54909
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54909&action=edit
Minimal testcase
On x86_64-pc-linux-gnu the attached code compiles (with -O3) to rather
unsatisfying assembly with a branch that does the same thing whether taken or
not:
> 10: 85 c0 test %eax,%eax
> 12: 74 04 je 18
> 14: c3 ret
> 15: 0f 1f 00 nopl (%rax)
> 18: c3 ret
I've tested on my machine in GCC 12.2.1, but Compiler Explorer (
https://godbolt.org/z/cW69rfrPc ) shows the same thing happens in a lot of
other versions, including trunk (6ab856aa49bef7c04efa6144a5048e129b3a058b).
Notably, this doesn't happen in GCC 4.5.3.
This seems to happen for a few other targets as well, e.g: arm, riscv32; but
not on some others, e.g. aarch64, mips.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug rtl-optimization/109601] Useless branch not eliminated when writing to a union
2023-04-23 18:26 [Bug target/109601] New: Useless branch not eliminated when writing to a union 67 at mniip dot com
@ 2023-04-23 18:48 ` pinskia at gcc dot gnu.org
2023-04-23 18:58 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-23 18:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109601
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
jump2 (which is after RA) does this for aarch64:
Forwarding edge 2->3 to 5 failed.
verify found no changes in insn with uid = 11.
Edge 2->4 redirected to 5
scanning new insn with uid = 47.
Replacing insn 11 by jump 47
deleting insn with uid = 11.
deleting insn with uid = 38.
deleting block 3
deleting block 4
Removing jump 47.
deleting insn with uid = 47.
Merging block 5 into block 2...
changing bb of uid 43
changing bb of uid 44
from 5 to 2
changing bb of uid 45
from 5 to 2
Merged blocks 2 and 5.
Merged 2 and 5 without moving.
For x86_64 does not have this.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug rtl-optimization/109601] Useless branch not eliminated when writing to a union
2023-04-23 18:26 [Bug target/109601] New: Useless branch not eliminated when writing to a union 67 at mniip dot com
2023-04-23 18:48 ` [Bug rtl-optimization/109601] " pinskia at gcc dot gnu.org
@ 2023-04-23 18:58 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-23 18:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109601
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-04-23
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
x86 duplicated the simple return but never unduplicates it:
(jump_insn 27 12 28 3 (simple_return) 1030 {simple_return_internal}
(nil)
-> simple_return)
...
(jump_insn 32 31 33 4 (simple_return) "/app/example.cpp":29:1 -1
(nil)
-> simple_return)
But simple_return was only added in GCC 4.7.0 (r0-111280-g268987713c7105c691)
So something else changed.
There is also a missed optimization earlier because jump2 is way late to be
optimizing this case.
Also this is just an issue with return so it might not be as important as most
people think (the other missed optimization earlier is though).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-23 18:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23 18:26 [Bug target/109601] New: Useless branch not eliminated when writing to a union 67 at mniip dot com
2023-04-23 18:48 ` [Bug rtl-optimization/109601] " pinskia at gcc dot gnu.org
2023-04-23 18:58 ` 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).