public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Disable loop2_invariant for -Os
@ 2012-06-27  8:48 Zhenqiang Chen
  0 siblings, 0 replies; 9+ messages in thread
From: Zhenqiang Chen @ 2012-06-27  8:48 UTC (permalink / raw)
  To: gcc-patches

Hi,

In general, invariant motion itself can not reduce code size. But it will
change the liverange of the invariant, which might lead to more spilling.
The patch disables loop2_invariant when optimizing for size.

I measured the code size benefit for four targets based on CSiBE benchmark:

ARM: 0.33%
MIPS: 1.15%
PPC: 0.24%
X86: 0.45%

Is it OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2012-06-27  Zhenqiang Chen <zhenqiang.chen@arm.com>

	* loop-init.c (gate_rtl_move_loop_invariants): Disable
loop2_invariant
	when optimizing function for size.

diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 03f8f61..5d8cf73 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -273,6 +273,12 @@ struct rtl_opt_pass pass_rtl_loop_done =
 static bool
 gate_rtl_move_loop_invariants (void)
 {
+  /* In general, invariant motion can not reduce code size. But it will
+     change the liverange of the invariant, which increases the register
+     pressure and might lead to more spilling.  */
+  if (optimize_function_for_size_p (cfun))
+    return false;
+
   return flag_move_loop_invariants;
 }



^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <4feac6f5.4abd440a.074d.ffffcfbaSMTPIN_ADDED@mx.google.com>]
[parent not found: <4feac6fa.e288440a.73b3.ffffa5c7SMTPIN_ADDED@mx.google.com>]

end of thread, other threads:[~2012-07-09  8:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27  8:48 [PATCH] Disable loop2_invariant for -Os Zhenqiang Chen
     [not found] <4feac6f5.4abd440a.074d.ffffcfbaSMTPIN_ADDED@mx.google.com>
2012-06-27  9:09 ` Richard Guenther
2012-06-28  9:03   ` Zhenqiang Chen
     [not found]   ` <4fec169c.e908b40a.26d1.ffffc3f1SMTPIN_ADDED@mx.google.com>
2012-06-28  9:38     ` Richard Guenther
2012-07-03  8:29       ` Zhenqiang Chen
     [not found]       ` <4ff2ad57.8aa0d80a.5910.ffffb0d6SMTPIN_ADDED@mx.google.com>
2012-07-03  9:32         ` Richard Guenther
2012-07-09  8:40           ` Zhenqiang Chen
     [not found] <4feac6fa.e288440a.73b3.ffffa5c7SMTPIN_ADDED@mx.google.com>
2012-06-27  9:53 ` Steven Bosscher
2012-06-28  9:05   ` Zhenqiang Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).