Update passes to use optimize_*_for_size_p tests
Jan Hubicka
jh@suse.cz
Sat Aug 30 14:06:00 GMT 2008
> On Fri, Aug 29, 2008 at 1:30 AM, Jan Hubicka <jh@suse.cz> wrote:
> > Hi,
> > this patch updates current tests for optimize_size and maybe_hot_bb* for
> > optimize*_for_size_p. I've also added optimize_loop_for_size_p as there seems
> > to be some confussion in loop optimizer on how to identify loops to be
> > optimized aggressivly and removed from opts.c code disabling passes on
> > optimize_size that now can work that out from profile.
> >
> > Bootstrapped/regtested i686-linux, will commit it tomorrow if there are no complains.
> >
> ===================================================================
> > *** loop-unswitch.c (revision 139737)
> > --- loop-unswitch.c (working copy)
> > *************** unswitch_single_loop (struct loop *loop,
> > *** 290,296 ****
> > }
> >
> > /* Do not unswitch in cold areas. */
> > ! if (!maybe_hot_bb_p (loop->header))
> > {
> > if (dump_file)
> > fprintf (dump_file, ";; Not unswitching, not hot area\n");
> > --- 290,296 ----
> > }
> >
> > /* Do not unswitch in cold areas. */
> > ! if (optimize_loop_for_speed_p (loop))
>
> The change looks backward.
Indeed it is. I am always trying to double check the changes, but
missed this one, thanks!
>
>
>
> > *** tree-ssa-loop-ch.c (revision 139737)
> > --- tree-ssa-loop-ch.c (working copy)
> > *************** should_duplicate_loop_header_p (basic_bl
> > *** 58,63 ****
> > --- 58,70 ----
> > if (header->aux)
> > return false;
> >
> > + /* Loop header copying usually increases size of the code. This used not to
> > + be true, since quite often it is possible to verify that the condition is
> > + satisfied in the first iteration and therefore to eliminate it. Jump
> > + threading handles these cases now. */
> > + if (optimize_loop_for_size_p (loop))
> > + return false;
> > +
>
> It would be nice to do this change separately.
OK, I've comitted this hunk now and re-testing the overall patch.
Thanks!
Index: ChangeLog
===================================================================
*** ChangeLog (revision 139755)
--- ChangeLog (working copy)
***************
*** 1,5 ****
--- 1,16 ----
2008-08-29 Jan Hubicka <jh@suse.cz>
+ * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Check that loop
+ is not cold.
+ * predict.c (optimize_bb_for_size_p, optimize_bb_for_speed_p):
+ Constify arguments.
+ (optimize_loop_for_size_p, optimize_loop_for_speed_p): New functions.
+ * basic-block.h (optimize_bb_for_size_p, optimize_bb_for_speed_p):
+ Constify.
+ (optimize_loop_for_size_p, optimize_loop_for_speed_p): Declare.
+
+ 2008-08-29 Jan Hubicka <jh@suse.cz>
+
* tree-pass.h (pass_strip_predict_hints): Declare.
* predict.c (strip_builtin_expect): Rename to ...
(strip_predict_hints): ... this one; strip also GIMPLE_PREDICT.
Index: tree-ssa-loop-ch.c
===================================================================
*** tree-ssa-loop-ch.c (revision 139754)
--- tree-ssa-loop-ch.c (working copy)
*************** should_duplicate_loop_header_p (basic_bl
*** 58,63 ****
--- 58,70 ----
if (header->aux)
return false;
+ /* Loop header copying usually increases size of the code. This used not to
+ be true, since quite often it is possible to verify that the condition is
+ satisfied in the first iteration and therefore to eliminate it. Jump
+ threading handles these cases now. */
+ if (optimize_loop_for_size_p (loop))
+ return false;
+
gcc_assert (EDGE_COUNT (header->succs) > 0);
if (single_succ_p (header))
return false;
Index: predict.c
===================================================================
*** predict.c (revision 139755)
--- predict.c (working copy)
*************** optimize_function_for_speed_p (struct fu
*** 200,206 ****
/* Return TRUE when BB should be optimized for size. */
bool
! optimize_bb_for_size_p (basic_block bb)
{
return optimize_function_for_size_p (cfun) || !maybe_hot_bb_p (bb);
}
--- 200,206 ----
/* Return TRUE when BB should be optimized for size. */
bool
! optimize_bb_for_size_p (const_basic_block bb)
{
return optimize_function_for_size_p (cfun) || !maybe_hot_bb_p (bb);
}
*************** optimize_bb_for_size_p (basic_block bb)
*** 208,214 ****
/* Return TRUE when BB should be optimized for speed. */
bool
! optimize_bb_for_speed_p (basic_block bb)
{
return !optimize_bb_for_size_p (bb);
}
--- 208,214 ----
/* Return TRUE when BB should be optimized for speed. */
bool
! optimize_bb_for_speed_p (const_basic_block bb)
{
return !optimize_bb_for_size_p (bb);
}
*************** optimize_insn_for_speed_p (void)
*** 245,250 ****
--- 245,266 ----
return !optimize_insn_for_size_p ();
}
+ /* Return TRUE when LOOP should be optimized for size. */
+
+ bool
+ optimize_loop_for_size_p (struct loop *loop)
+ {
+ return optimize_bb_for_size_p (loop->header);
+ }
+
+ /* Return TRUE when LOOP should be optimized for speed. */
+
+ bool
+ optimize_loop_for_speed_p (struct loop *loop)
+ {
+ return optimize_bb_for_speed_p (loop->header);
+ }
+
/* Set RTL expansion for BB profile. */
void
Index: basic-block.h
===================================================================
*** basic-block.h (revision 139754)
--- basic-block.h (working copy)
*************** extern bool maybe_hot_bb_p (const_basic_
*** 831,844 ****
extern bool maybe_hot_edge_p (edge);
extern bool probably_cold_bb_p (const_basic_block);
extern bool probably_never_executed_bb_p (const_basic_block);
! extern bool optimize_bb_for_size_p (basic_block);
! extern bool optimize_bb_for_speed_p (basic_block);
extern bool optimize_edge_for_size_p (edge);
extern bool optimize_edge_for_speed_p (edge);
extern bool optimize_insn_for_size_p (void);
extern bool optimize_insn_for_speed_p (void);
extern bool optimize_function_for_size_p (struct function *);
extern bool optimize_function_for_speed_p (struct function *);
extern bool gimple_predicted_by_p (const_basic_block, enum br_predictor);
extern bool rtl_predicted_by_p (const_basic_block, enum br_predictor);
extern void gimple_predict_edge (edge, enum br_predictor, int);
--- 831,846 ----
extern bool maybe_hot_edge_p (edge);
extern bool probably_cold_bb_p (const_basic_block);
extern bool probably_never_executed_bb_p (const_basic_block);
! extern bool optimize_bb_for_size_p (const_basic_block);
! extern bool optimize_bb_for_speed_p (const_basic_block);
extern bool optimize_edge_for_size_p (edge);
extern bool optimize_edge_for_speed_p (edge);
extern bool optimize_insn_for_size_p (void);
extern bool optimize_insn_for_speed_p (void);
extern bool optimize_function_for_size_p (struct function *);
extern bool optimize_function_for_speed_p (struct function *);
+ extern bool optimize_loop_for_size_p (struct loop *);
+ extern bool optimize_loop_for_speed_p (struct loop *);
extern bool gimple_predicted_by_p (const_basic_block, enum br_predictor);
extern bool rtl_predicted_by_p (const_basic_block, enum br_predictor);
extern void gimple_predict_edge (edge, enum br_predictor, int);
More information about the Gcc-patches
mailing list