]> git.ipfire.org Git - thirdparty/gcc.git/commit
ipa: Avoid IPA confusing scalar values and single-field aggregates (PR 108679)
authorMartin Jambor <mjambor@suse.cz>
Wed, 15 Feb 2023 10:38:01 +0000 (11:38 +0100)
committerMartin Jambor <mjambor@suse.cz>
Wed, 15 Feb 2023 10:38:07 +0000 (11:38 +0100)
commit8b1b1b2d691d5cee4ebc40a01974ad5bccab22f9
treec58781834c883b2cb23c84b21049eda00e878fd8
parent7a8cada824c5e45ea729c112f3d1d29956067b7b
ipa: Avoid IPA confusing scalar values and single-field aggregates (PR 108679)

PR 108679 testcase shows a situation when IPA-CP is able to track a
scalar constant in a single-field structure that is part of a bigger
structure.  This smaller structure is however also passed in a few
calls to other functions, but the two same-but-different entities,
originally placed at the same offset and with the same size, confuse
the mechanism that takes care of handling call statements after
IPA-SRA.

I think that in stage 4 it is best to revert to GCC 12 behavior in this
particular case (when IPA-CP detects a constant in a single-field
structure or a single element array that is part of a bigger aggregate)
and the patch below does that.  If accepted, I plan to file a
missed-optimization bug to track that we could use the IPA-CP propagated
value to re-construct the small aggregate arguments.

gcc/ChangeLog:

2023-02-13  Martin Jambor  <mjambor@suse.cz>

PR ipa/108679
* ipa-sra.cc (push_param_adjustments_for_index): Do not omit
creation of non-scalar replacements even if IPA-CP knows their
contents.

gcc/testsuite/ChangeLog:

2023-02-13  Martin Jambor  <mjambor@suse.cz>

PR ipa/108679
* gcc.dg/ipa/pr108679.c: New test.
gcc/ipa-sra.cc
gcc/testsuite/gcc.dg/ipa/pr108679.c [new file with mode: 0644]