]> git.ipfire.org Git - thirdparty/gcc.git/commit
ICF&SRA: Make ICF and SRA agree on padding
authorMartin Jambor <mjambor@suse.cz>
Mon, 8 Apr 2024 16:53:23 +0000 (18:53 +0200)
committerMartin Jambor <mjambor@suse.cz>
Mon, 8 Apr 2024 16:54:21 +0000 (18:54 +0200)
commit1e3312a25a7b34d6e3f549273e1674c7114e4408
tree6cc160ba4f8c660abdba701df11936f8f347e4bb
parent1162861439fd3c4b30fc3ccd49462e47e876f04a
ICF&SRA: Make ICF and SRA agree on padding

PR 113359 shows that (at least with -fno-strict-aliasing) ICF can
unify two functions which copy an aggregate type of the same size but
then SRA, through its total scalarization, can copy the aggregate by
pieces, skipping paddding, but the padding was not the same in the two
original functions that ICF unified.

This patch enhances SRA with the ability to collect padding
information which then can be compared from within ICF.  Unfortunately
SRA uses OPTION_SET_P when determining its limits, so ICF needs to
switch cfuns at least once to figure it out too.

gcc/ChangeLog:

2024-03-27  Martin Jambor  <mjambor@suse.cz>

PR ipa/113359
* ipa-icf-gimple.h (func_checker): New members
safe_for_total_scalarization_p, m_total_scalarization_limit_known_p
and m_total_scalarization_limit.
(func_checker::func_checker): Initialize new member variables.
* ipa-icf-gimple.cc: Include tree-sra.h.
(func_checker::func_checker): Initialize new member variables.
(func_checker::safe_for_total_scalarization_p): New function.
(func_checker::compare_operand): Use the new function.
* tree-sra.h (sra_get_max_scalarization_size): Declare.
(sra_total_scalarization_would_copy_same_data_p): Likewise.
* tree-sra.cc (prepare_iteration_over_array_elts): New function.
(class sra_padding_collecting): New.
(sra_padding_collecting::record_padding): Likewise.
(scalarizable_type_p): Rename to totally_scalarizable_type_p.  Add
ability to record padding when requested.
(totally_scalarize_subtree): Split out gathering information necessary
to iterate over array elements to prepare_iteration_over_array_elts.
Fix errornous early exit.
(analyze_all_variable_accesses): Adjust the call to
totally_scalarizable_type_p.  Move determining of total scalariation
size limit...
(sra_get_max_scalarization_size): ...here.
(check_ts_and_push_padding_to_vec): New function.
(sra_total_scalarization_would_copy_same_data_p): Likewise.

gcc/testsuite/ChangeLog:

2024-03-27  Martin Jambor  <mjambor@suse.cz>

PR ipa/113359
* gcc.dg/lto/pr113359-1_0.c: New.
* gcc.dg/lto/pr113359-1_1.c: Likewise.
* gcc.dg/lto/pr113359-2_0.c: Likewise.
* gcc.dg/lto/pr113359-2_1.c: Likewise.
* gcc.dg/lto/pr113359-3_0.c: Likewise.
* gcc.dg/lto/pr113359-3_1.c: Likewise.
* gcc.dg/lto/pr113359-4_0.c: Likewise.
* gcc.dg/lto/pr113359-4_1.c: Likewise.
* gcc.dg/lto/pr113359-5_0.c: Likewise.
* gcc.dg/lto/pr113359-5_1.c: Likewise.
14 files changed:
gcc/ipa-icf-gimple.cc
gcc/ipa-icf-gimple.h
gcc/testsuite/gcc.dg/lto/pr113359-1_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-1_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-2_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-2_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-3_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-3_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-4_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-4_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-5_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr113359-5_1.c [new file with mode: 0644]
gcc/tree-sra.cc
gcc/tree-sra.h