This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR 10011: Introduce gcse_constant_p
- From: Richard Henderson <rth at redhat dot com>
- To: Roger Sayle <roger at www dot eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 30 Mar 2003 15:17:37 -0800
- Subject: Re: [PATCH] PR 10011: Introduce gcse_constant_p
- References: <Pine.LNX.4.44.0303161824060.4193-100000@www.eyesopen.com>
On Sun, Mar 16, 2003 at 06:51:37PM -0700, Roger Sayle wrote:
> PR middle-end/10011
> * gcse.c (gcse_constant_p): New function to identify constants
> suitable for constant propagation, including COMPARE with two
> integer constant arguments.
> (hash_scan_set): Use gcse_constant_p.
> (find_avail_set): Likewise.
> (cprop_insn): Likewise.
> (do_local_cprop): Likewise.
> (find_implicit_sets): Likewise.
> (find_bypass_set): Likewise.
This is ok, since it is a nice cleanup, but I don't think this is
the whole story. The real problem, as I see it, is that
purge_builtin_constant_p is being run too late.
In particular, what happens in each case is that we purge the
constant_p_rtx, replace it with a zero, and then loop optimization
moves the assignment out of the loop before the branch is simplfied.
If we run this a bit ealier, then the post-gcse cse pass will take
care of this.
Indeed, this change by itself fixes both prs.
r~
* toplev.c (rest_of_compilation): Run purge_builtin_constant_p
before post-gcse cse pass.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.737
diff -c -p -d -u -r1.737 toplev.c
--- toplev.c 24 Mar 2003 20:44:54 -0000 1.737
+++ toplev.c 30 Mar 2003 23:11:19 -0000
@@ -2929,6 +2929,10 @@ rest_of_compilation (decl)
save_cfj = flag_cse_follow_jumps;
flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
+ /* Instantiate any remaining CONSTANT_P_RTX nodes. */
+ if (current_function_calls_constant_p)
+ purge_builtin_constant_p ();
+
/* If -fexpensive-optimizations, re-run CSE to clean up things done
by gcse. */
if (flag_expensive_optimizations)
@@ -2973,10 +2977,6 @@ rest_of_compilation (decl)
verify_flow_info ();
#endif
}
-
- /* Instantiate any remaining CONSTANT_P_RTX nodes. */
- if (optimize > 0 && flag_gcse && current_function_calls_constant_p)
- purge_builtin_constant_p ();
/* Move constant computations out of loops. */