[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 Andrew Pinski changed: What|Removed |Added Blocks||101926 --- Comment #9 from Andrew Pinski --- (In reply to Marc Glisse from comment #2) > Or with less templates: This one was fixed in GCC 15. Comment #0 is still not fixed. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101926 [Bug 101926] [meta-bug] struct/complex/other argument passing and return should be improved
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 Andrew Pinski changed: What|Removed |Added CC||cfsteefel at arista dot com --- Comment #7 from Andrew Pinski --- *** Bug 110648 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 Andrew Pinski changed: What|Removed |Added CC||madhur4127 at gmail dot com --- Comment #8 from Andrew Pinski --- *** Bug 116414 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 Andrew Pinski changed: What|Removed |Added CC||tnfchris at gcc dot gnu.org --- Comment #6 from Andrew Pinski --- *** Bug 101326 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 --- Comment #5 from Andrew Pinski --- *** Bug 95383 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384
--- Comment #4 from Barry Revzin ---
Here's another example of the same kind of issue
(https://godbolt.org/z/KWr9rMssj):
template
struct tagged_union {
tagged_union(T t) : index(0), a(t) { }
tagged_union(U u) : index(1), b(u) { }
union {
T a;
U b;
};
char index;
};
struct X { int i; };
struct Y { int j; };
tagged_union as_tagged_union(X x) {
return x;
}
template
struct tagged_union_wrapped : tagged_union {
using tagged_union::tagged_union;
};
auto as_tagged_union2(X x) {
return tagged_union_wrapped(x);
}
this on -O3 emits:
as_tagged_union(X):
mov eax, edi
ret
as_tagged_union2(X):
mov DWORD PTR [rsp-8], edi
mov BYTE PTR [rsp-4], 0
mov rax, QWORD PTR [rsp-8]
ret
If you change the index member from 'char' to 'int', causing the tail padding
to disappear, as_tagged_union2 improves to the same code gen as
as_tagged_union.
This is relevant for std::variant performance. std::variant behaves like
tagged_union_wrapped, whereas if you drop down to the implementation
details and directly use _Variant_storage_alias, that behaves like
tagged_union for these purposes.
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 Andrew Pinski changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed||2021-08-04 --- Comment #3 from Andrew Pinski --- Confirmed. All bad around. I wonder if we could "expose" some of the details of the ABI late in gimple to simplify/solve this.
[Bug tree-optimization/95384] Poor codegen cause by using base class instead of member for Optional construction
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95384 Andrew Pinski changed: What|Removed |Added Component|c++ |tree-optimization Severity|normal |enhancement
