[Bug c++/105260] Union with user-defined empty destructor leads to worse code-gen

jamborm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 13 16:08:49 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105260

--- Comment #8 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #7)
> Or find out why SRA doesn't optimize this (remove the useless union, replace
> all the un.value occurrences with a var with Foo type.

IIUC, it just isn't profitable, SRA sees:

  un.value = D.2545;
  dummyFunc (MEM[(const struct Foo &)&un]);
  un ={v} {CLOBBER(eol)};

and it just cannot avoid ultimately setting up the structure and pass
it to dummyFunc (IPA-SRA does not control that function and so cannot
change it).


More information about the Gcc-bugs mailing list