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

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).