This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Extend store ccp
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Revital1 Eres" <ERES at il dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, rguenther.suse <rguenther dot suse%de at il dot ibm dot com>, "Ayal Zaks" <ZAKS at il dot ibm dot com>, "Dorit Nuzman" <DORIT at il dot ibm dot com>, "Victor Kaplansky" <VICTORK at il dot ibm dot com>
- Date: Fri, 23 Mar 2007 10:45:22 +0100
- Subject: Re: [PATCH] Extend store ccp
- References: <OF09DF30BA.F4A49513-ONC22572A6.006C40BC-C22572A7.001DDD36@il.ibm.com>
On 3/23/07, Revital1 Eres <ERES@il.ibm.com> wrote:
Hello,
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.
(http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00669.html)
Bootstrap and tested on PPC. OK for mainline?
You confused me a lot in that you use a name for get_def_of_stmt_rhs ()
that doesn't look like it checks for a single constant value ;) Maybe
just make it return true or false and call it stmt_rhs_constant_val_p
(stmt, val).
Or even fold it into it's only use, all_vdef_have_same_lattice_const_value.
Did you check compile-time and runtime effects of this patch like on SPEC? I
suppose we can eliminate array zero initialization if there follows
different initialzation
with this patch.
Thanks,
Richard.
:ADDPATCH tree-ssa optimization:
Thanks,
Revital
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
stmt.
(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):
Declare.
(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
while
performing the propogation.
* tree-ssa-copy.c (fini_copy_prop): Call substitute_and_fold with
new
argument.
* testsuite/gcc.dg/store_ccp_test.c: New test.
(See attached file: patch_ccp_22_3.txt)(See attached file:
store_ccp_test.txt)