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

--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 15 Apr 2025, uecker at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119792
> 
> --- Comment #9 from uecker at gcc dot gnu.org ---
> 
> If the problem is that useless_type_conversion_p should not return true for
> certain types with the same TYPE_CANONICAL,  shouldn't we simply add back the
> test for the size of the FAM here to useless_type_conversion_p?

That would be a quite expensive thing to do.  TYPE_CANONICAL was
supposed to be at most "structurally equivalent", in particular
the sizes of types with the same TYPE_CANONICAL should either
be the same or they should be incomplete.

Basically TYPE_CANONICAL should form a type system in the middle-end
we can map all frontend type systems to.  There was the neat goal
that it should be possible to map TBAA to the very same, but examples
like C FAM shows this might be not achievable?

Note the issue we run into with C vs. Ada is that LTO attempts
to re-compute TYPE_CANONICAL by making it "most conservative"
via applying that "structurally equivalent" logic - very much what
for frontends is to set TYPE_STRUCTURAL_EQUALITY_P.  But that
does not seem to mix with C FAM which are _not_ structurally
equivalent(?).  So the problematic change was to this logic which
made TBAA more conservative but broke the type system in that
information is lost that was present in conversions that are now
considered useless (carrying no middle-end relevant information).

I lack a total complete picture to see a possible solution here.
One might be to keep TYPE_CANONICAL different but make
get_alias_set somehow compute the same alias-sets (possibly in
a way that might also fix that drat common initial sequence
rule) via record_component_aliases.  No idea how though.
Adding yet another field - TYPE_CANONICAL_FOR_TBAA (yuk) - would
be the most stupid solution, we'd have to somehow stream that
and unify the sets when they get related by TYPE_CANONICAL
merging.  It would be a half-attempt at dissecting the type
system from TBAA.

Reply via email to