]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-sra: Do not create stores into const aggregates (PR111873)
authorMartin Jambor <mjambor@suse.cz>
Wed, 14 May 2025 10:08:24 +0000 (12:08 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Wed, 14 May 2025 10:08:28 +0000 (12:08 +0200)
commit9d039eff453f777c58642ff16178c1ce2a4be6ab
treed2c251ab89e053e666fa6fb735013039ba708341
parentd787bc4fd372298e9ed5b11cb3050fd3707070f6
tree-sra: Do not create stores into const aggregates (PR111873)

This patch fixes (hopefully the) one remaining place where gimple SRA
was still creating a load into const aggregates.  It occurs when there
is a replacement for a load but that replacement is not type
compatible - typically because it is a single field structure.

I have used testcases from duplicates because the original test-case
no longer reproduces for me.

gcc/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/111873
* tree-sra.cc (sra_modify_expr): When processing a load which has
a type-incompatible replacement, do not store the contents of the
replacement into the original aggregate when that aggregate is
const.

gcc/testsuite/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/ipa/pr120044-1.c: New test.
* gcc.dg/ipa/pr120044-2.c: Likewise.
* gcc.dg/tree-ssa/pr114864.c: Likewise.
gcc/testsuite/gcc.dg/ipa/pr120044-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/ipa/pr120044-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr114864.c [new file with mode: 0644]
gcc/tree-sra.cc