https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119835
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- We can try making gimplification less dependent on the target here and simply use else if (!is_gimple_reg_type (TREE_TYPE (result_decl))) { ... instead of checking aggregate_value_p. That might in theory pessimize cases where things like struct { int a; } are returned in a register and thus SRA would not be able to optimize this since IIRC that cannot handle GIMPLE return stmts. But it might be worth a try? Likewise just using AGGREGATE_TYPE_P (..) above. Note there's correctness parts of aggregate_value_p, like the TREE_ADDRESSABLE check on the type, but IIRC that's only ever relevant for aggregate types. The TYPE_TRANSPARENT_AGGR handling might be also useful to replicate. Everything else should be only relevant to RTL, but eventually RTL expansion relies on gimplification handling those cases in some special way. Who knows.