This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH GCC]Support load in CT_STORE_STORE chain if dominated by store in the same loop iteration


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]