> On Sep 17, 2025, at 12:11, Jakub Jelinek <[email protected]> wrote:
>
> On Wed, Sep 17, 2025 at 05:59:34PM +0200, Martin Jambor wrote:
>> Hi,
>>
>> On Fri, Sep 12 2025, Qing Zhao wrote:
>>> In tree-sra.cc, for the following stmt (initialization in source code):
>>> s = {};
>>>
>>> for the above lhs "s", the field "grp_assignment_write" of the created
>>> struct access is 1;
>>>
>>> however, for the following stmt (compiler added initialization):
>>> s = .DEFERRED_INIT (size, init_type, &"s"[0]);
>>>
>>> for the above lhs "s", the field "grp_assignment_write" of the created
>>> struct access is 0;
>>>
>>> Since the field "grp_assignment_write" of the struct access for the
>>> corresponding LHS "s" is not set correctly when the RHS is .DEFERRED_INIT,
>>> SRA phase didn't do a correct transformation for call to .DEFERRED_INIT.
>>>
>>> To fix this issue, we should set the field "grp_assignment_write" correctly
>>> for .DEFERRED_INIT.
>>>
>>> PR 121894
>
> This should be
> PR tree-optimization/121894
Okay.
>
>>>
>>> gcc/ChangeLog:
>>>
>>> * tree-sra.cc (scan_function): Set grp_assignment_write to 1 when
>>> specially handle call to .DEFERRED_INIT.
>>
>> I cannot approve the change but I think it makes sense.
>
> LGTM then with nits.
>
>>> gcc/testsuite/ChangeLog:
>>>
>>> * g++.dg/auto-init-sra-pr121894.C: New test.
>
> Please move the test into g++.dg/opt/ directory or g++.dg/tree-ssa/.
> g++.dg/ ideally shouldn't have any tests directly in it.
Sure, will do that before committing.
thanks.
Qing
>
> Jakub