Hi,

> On 10 Jun 2026, at 9:37 pm, [email protected] wrote:
> 
> +         /* A by-value aggregate return ("T t = ...; return t;") stores the
> +            result into the return slot.  Under the return-slot optimization 
> the
> +            inlined callee writes the caller's destination in place and SRA 
> then
> +            scalarises the small aggregate, so the store is eliminated by 
> inlining
> +            -- the return-value analogue of the by-reference parameter reads
> +            credited above.  The is_gimple_reg/is_gimple_min_invariant test 
> only
> +            credits scalar returns; also credit an aggregate return whose 
> source is
> +            an ordinary memory value.  This is the value-type wrapper idiom
> +            (a SIMD/array lane type, std::array, std::complex, a short 
> Tensor):
> +            "T operator OP (const T &a, const T &b) { T t = a; t OP= b; 
> return t; }".
> +            This is the whole-aggregate-copy case.  */
> +         if (!rhs_free
> +             && !gimple_has_volatile_ops (stmt)
> +             && AGGREGATE_TYPE_P (TREE_TYPE (lhs))
> +             && gimple_assign_rhs_class (stmt) == GIMPLE_SINGLE_RHS
> +             && (TREE_CODE (inner_lhs) == RESULT_DECL
> +                 || (TREE_CODE (inner_lhs) == MEM_REF
> +                     && TREE_CODE (TREE_OPERAND (inner_lhs, 0)) == SSA_NAME
> +                     && SSA_NAME_VAR (TREE_OPERAND (inner_lhs, 0))
> +                     && TREE_CODE (SSA_NAME_VAR (TREE_OPERAND (inner_lhs, 
> 0)))
> +                        == RESULT_DECL))
> +             && (TREE_CODE (inner_rhs) == MEM_REF
> +                 || TREE_CODE (inner_rhs) == COMPONENT_REF
> +                 || VAR_P (inner_rhs)
> +                 || TREE_CODE (inner_rhs) == PARM_DECL
> +                 || TREE_CODE (inner_rhs) == RESULT_DECL))
> +           return 2;

Should we also check if this is Automatic local? 
Like VAR_P (inner_rhs) && auto_var_in_fn_p (inner_rhs, current_function_decl)

Thanks,
Kugan


Reply via email to