[patch] fix pr22550
Diego Novillo
dnovillo@redhat.com
Fri Jul 29 16:37:00 GMT 2005
On Thu, Jul 28, 2005 at 11:30:04AM -0600, Jeffrey A Law wrote:
> On Thu, 2005-07-28 at 11:56 -0400, Diego Novillo wrote:
>
> > I experimented with both approaches and, contrary to what I had
> > expected, iterating inside CFG cleanup is the winner. Both
> > patches are attached.
> Wow. I never would have expected this...
>
Yeah. So much for gut feelings, eh? ;)
> Hmmm, I can hazard a guess it's more a matter of preventing DOM
> iteration rather than fewer opportunities for DOM.
>
Ah, yes. I had forgotten about DOM iterations. And indeed that
explains the difference:
Number of DOM iterations Before After % diff
cc1-i-files 59000 52542 -10.95%
DLV 11478 10095 -12.05%
MICO 33032 30912 - 6.42%
SPEC2000 25382 22704 -10.55%
TRAMP3D 4234 3360 -20.64%
pr12850 5069 3790 -25.23%
This is what I committed.
PR 22550
* tree-cfgcleanup.c (cleanup_tree_cfg_1): Extract from ...
(cleanup_tree_cfg): ... here.
Call cleanup_tree_cfg_1 until there are no more cleanups to
do.
testsuite/ChangeLog
PR 22550
* g++.dg/tree-ssa/pr22550.C: New test.
Index: tree-cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfgcleanup.c,v
retrieving revision 2.3
diff -d -u -p -r2.3 tree-cfgcleanup.c
--- tree-cfgcleanup.c 18 Jul 2005 23:20:09 -0000 2.3
+++ tree-cfgcleanup.c 29 Jul 2005 16:26:26 -0000
@@ -489,14 +489,12 @@ cleanup_forwarder_blocks (void)
return changed;
}
-/* Remove unreachable blocks and other miscellaneous clean up work. */
+/* Do one round of CFG cleanup. */
-bool
-cleanup_tree_cfg (void)
+static bool
+cleanup_tree_cfg_1 (void)
{
- bool retval = false;
-
- timevar_push (TV_TREE_CLEANUP_CFG);
+ bool retval;
retval = cleanup_control_flow ();
retval |= delete_unreachable_blocks ();
@@ -516,6 +514,28 @@ cleanup_tree_cfg (void)
end_recording_case_labels ();
}
+ /* Merging the blocks may create new opportunities for folding
+ conditional branches (due to the elimination of single-valued PHI
+ nodes). */
+ retval |= merge_seq_blocks ();
+
+ return retval;
+}
+
+
+/* Remove unreachable blocks and other miscellaneous clean up work. */
+
+bool
+cleanup_tree_cfg (void)
+{
+ bool retval;
+ int i;
+
+ timevar_push (TV_TREE_CLEANUP_CFG);
+
+ for (retval = true, i = 0; i < 5 && retval; i++)
+ retval = cleanup_tree_cfg_1 ();
+
#ifdef ENABLE_CHECKING
if (retval)
{
@@ -526,16 +546,14 @@ cleanup_tree_cfg (void)
}
#endif
- /* Merging the blocks creates no new opportunities for the other
- optimizations, so do it here. */
- retval |= merge_seq_blocks ();
-
compact_blocks ();
#ifdef ENABLE_CHECKING
verify_flow_info ();
#endif
+
timevar_pop (TV_TREE_CLEANUP_CFG);
+
return retval;
}
Index: testsuite/g++.dg/tree-ssa/pr22550.C
===================================================================
RCS file: testsuite/g++.dg/tree-ssa/pr22550.C
diff -N testsuite/g++.dg/tree-ssa/pr22550.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/tree-ssa/pr22550.C 29 Jul 2005 16:26:33 -0000
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+class X {
+public:
+ int mfunc1 () {
+ return 1;
+ }
+ int mfunc2 () {
+ return 2;
+ }
+ X (int a, int b) { }
+};
+
+typedef int (X::*memfunc_p_t) ();
+
+memfunc_p_t mf_arr[2] = { &X::mfunc1, &X::mfunc2 };
+
+int
+main ()
+{
+ // Get pntr to the array of pointers to member-funcs
+ memfunc_p_t (*mf_arr_p)[2] = &mf_arr;
+ // Compare indirect against direct access to an array element
+ if ((*mf_arr_p)[0] != mf_arr[0])
+ return 1;
+ return 0;
+}
More information about the Gcc-patches
mailing list