[PATCH GCC]Support load in CT_STORE_STORE chain if dominated by store in the same loop iteration
Bin Cheng
Bin.Cheng@arm.com
Fri Nov 17 13:58:00 GMT 2017
Hi,
I previously introduced CT_STORE_STORE chains in predcom. This patch further supports load
reference in CT_STORE_STORE chain if the load is dominated by a store reference in the same
loop iteration. So example as in added test case:
for (i = 0; i < len; i++)
{
a[i] = t1;
a[i + 3] = t2;
a[i + 1] = -1;
sum = sum + a[i] + a[i + 3];
}
can be transformed into:
for (i = 0; i < len; i++)
{
a[i] = t1;
a[i + 3] = t2;
a[i + 1] = -1;
sum = sum + t1 + t2;
}
Before this patch, we can't eliminate load because no load reference is allowed in CT_STORE_STORE
chain.
This patch only supports it if the load is dominated by a store reference in the same loop
iteration. If we generalize this to load/store in arbitrary loop iterations, it basically
generalizes CT_STORE_LOAD/CT_STORE_STORE chains into arbitrary mixed chain. That would
need fundamental rewrite of the pass and not sure how useful it would be.
Bootstrap and test on x86_64 and AArch64. Is it OK?
Thanks,
bin
2017-11-15 Bin Cheng <bin.cheng@arm.com>
* tree-predcom.c: Add general comment on Store-Store chains.
(split_data_refs_to_components): Postpone clearing eliminate_store_p
flag in component.
(get_chain_last_ref_at): Rename into...
(get_chain_last_write_at): ...this.
(get_chain_last_write_before_load): New function.
(add_ref_to_chain): Promote type of chain from CT_STORE_LOAD to
CT_STORE_STORE when write reference is added.
(determine_roots_comp): Support load ref in CT_STORE_STORE chains.
(is_inv_store_elimination_chain): Update get_chain_last_write_at call.
(initialize_root_vars_store_elim_1): Ditto.
(initialize_root_vars_store_elim_2): Ditto. Replace rhs once default
definition is created.
(execute_pred_commoning_chain): Support load ref in CT_STORE_STORE
chain by replacing it with dominant stored value.
gcc/testsuite/ChangeLog
2017-11-15 Bin Cheng <bin.cheng@arm.com>
* gcc.dg/tree-ssa/predcom-dse-12.c: New test.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0002-restrict-store-mixed-chain-20171115.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171117/a012b36a/attachment.txt>
More information about the Gcc-patches
mailing list