This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH GCC]Support load in CT_STORE_STORE chain if dominated by store in the same loop iteration
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bin Cheng <Bin dot Cheng at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Mon, 20 Nov 2017 12:48:47 +0100
- Subject: Re: [PATCH GCC]Support load in CT_STORE_STORE chain if dominated by store in the same loop iteration
- Authentication-results: sourceware.org; auth=none
- References: <DB5PR0801MB2742C76F365A596815DF8C71E72F0@DB5PR0801MB2742.eurprd08.prod.outlook.com>
On Fri, Nov 17, 2017 at 2:49 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> 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?
Ok.
Thanks,
Richard.
> 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.