https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114574
--- Comment #31 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I've tried to construct a wrong-code testcase, but so far haven't been successful. In e.g. struct S { int s; } s; struct T { long l; } t; const struct S * foo (const struct S **p, const struct T **q) { *p = &s; *q = &t; return *p; } fre1 optimizes the return *p to return &s; So I've tried [[gnu::always_inline]] static inline const void * foo (void *x, bool y) { const struct S **p = (const struct S **) x; struct S { int s; }; static struct S s; if (y) *p = &s; return *p; } [[gnu::always_inline]] static inline void bar (void *x) { const struct S **q = (const struct S **) x; struct S { int s; }; static struct S s; *q = &s; } const void * baz (void *x, void *y) { foo (x, true); bar (y); return foo (x, false); } where without the posted patch I think the TYPE_CANONICAL on const struct S* should be wrong in the bar function, but strangely we don't optimize it.