This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/42720] Problematic condition simplification logic at unswitch-loops pass



------- Comment #8 from rakdver at gcc dot gnu dot org  2010-01-30 12:01 -------
(In reply to comment #7)
> Oh, and Zdenek might have an idea about the condition simplification in
> unswitching.

I agree that some of the checks in tree_unswitch_single_loop are badly placed
-- it does not make sense to check them repeatedly in the recursion.  I'd
suggest to move them to tree_ssa_unswitch_loops, i.e.,

Index: tree-ssa-loop-unswitch.c
===================================================================
*** tree-ssa-loop-unswitch.c    (revision 155960)
--- tree-ssa-loop-unswitch.c    (working copy)
*************** tree_ssa_unswitch_loops (void)
*** 88,93 ****
--- 88,113 ----
    /* 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);
      }

*************** tree_unswitch_single_loop (struct loop *
*** 189,219 ****
        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);

--- 209,214 ----


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42720


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]