[PATCH] Extend store ccp

Revital1 Eres ERES@il.ibm.com
Fri Mar 23 07:29:00 GMT 2007


This patch enhance store ccp to propagate constants from stores to
loads when the previous implementation failed due to alias uncertainty.
The testcase attached demonstrates this optimization:

S[5].x = 0;
S[5].y = 0;

x = S[5].x;
y = S[5].y;

Previously x = S[5].x; failed to be replaced with x = 0.  This patch
fixes this problem by allowing the propagation of constants if all the
stores in the alias group are initialized with the same constant.

I used the get_stmt_rhs_def_stmt () function Richard Guenther
introduced in his patch to walk the virtual def-use chains
with adjustments to make it suitable for this optimization.

Bootstrap and tested on PPC. OK for mainline?

:ADDPATCH tree-ssa optimization:


2007-03-22  Revital Eres  <eres@il.ibm.com>

        * tree-ssa-propagate.c (all_vdef_have_same_lattice_const_value):
          New function to get the defining stmt.
          (get_def_of_stmt_rhs): New helper function
          which walks on the virtual use-def chain to get the defining
          (replace_vuses_in): Call all_vdef_have_same_lattice_const_value
          to perform the final replacement and add new parameter which
          indicates whether store cpp analysis should be extended to
          analyze memory references based on the virtual use-def chain.
          (do_store_ccp): New function.
          (substitute_and_fold): Add new parameter.
        * tree-ssa-propagate.h (all_vdef_have_same_lattice_const_value):
           (substitute_and_fold): Change declaration.
        * tree-vrp.c (vrp_finalize): Call substitute_and_fold with new
argument .
        * tree-ssa-ccp.c (ccp_finalize): Likewise.
          (visit_assignment): Call all_vdef_have_same_lattice_const_value
           performing the propogation.
       * tree-ssa-copy.c (fini_copy_prop): Call substitute_and_fold with
        * testsuite/gcc.dg/store_ccp_test.c: New test.

(See attached file: patch_ccp_22_3.txt)(See attached file:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_ccp_22_3.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070323/fa0e04e1/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: store_ccp_test.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070323/fa0e04e1/attachment-0001.txt>

More information about the Gcc-patches mailing list