This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]PR tree-optimization/42720 Fixing problematic logic at unswitch-loops pass
- From: Jing Yu <jingyu at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: rakdver at gcc dot gnu dot org
- Date: Wed, 7 Apr 2010 16:59:47 -0700
- Subject: [PATCH]PR tree-optimization/42720 Fixing problematic logic at unswitch-loops pass
- References: <k2m85670fb81004071656k83bde950y463f48f156a01947@mail.gmail.com>
The patch came out of the discussion to fix the problematic logic at
unswitch-loops pass.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42720
2010-04-07? Jing Yu? <jingyu@google.com>
??????????? Zdenek Dvorak? <ook@ucw.cz>
??????? PR tree-optimization/42720
??????? * tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Move one-time
??????? loop unswitch conditions here from
??????? (tree_unswitch_single_loop).
I have tested the patch on top of trunk. The empty loop described in
the bugzilla entry is gone.
The results of dejagnu tests on arm-eabi target do not change with the patch.
OK for trunk?
Thanks,
Jing
Index: gcc/tree-ssa-loop-unswitch.c
===================================================================
--- gcc/tree-ssa-loop-unswitch.c (revision 158099)
+++ gcc/tree-ssa-loop-unswitch.c (working copy)
@@ -88,6 +88,26 @@ tree_ssa_unswitch_loops (void)
/* Go through inner loops (only original ones). */
FOR_EACH_LOOP (li, loop, LI_ONLY_INNERMOST)
{
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, ";; Considering loop %d\n", loop->num);
+
+ /* Do not unswitch in cold regions. */
+ if (optimize_loop_for_size_p (loop))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, ";; Not unswitching cold loops\n");
+ continue;
+ }
+
+ /* The loop should not be too large, to limit code growth. */
+ if (tree_num_loop_insns (loop, &eni_size_weights)
+ > (unsigned) PARAM_VALUE (PARAM_MAX_UNSWITCH_INSNS))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, ";; Not unswitching, loop too big\n");
+ continue;
+ }
+
changed |= tree_unswitch_single_loop (loop, 0);
}
@@ -189,31 +209,6 @@ tree_unswitch_single_loop (struct loop *
return false;
}
- /* Only unswitch innermost loops. */
- if (loop->inner)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, ";; Not unswitching, not innermost loop\n");
- return false;
- }
-
- /* Do not unswitch in cold regions. */
- if (optimize_loop_for_size_p (loop))
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, ";; Not unswitching cold loops\n");
- return false;
- }
-
- /* The loop should not be too large, to limit code growth. */
- if (tree_num_loop_insns (loop, &eni_size_weights)
- > (unsigned) PARAM_VALUE (PARAM_MAX_UNSWITCH_INSNS))
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, ";; Not unswitching, loop too big\n");
- return false;
- }
-
i = 0;
bbs = get_loop_body (loop);