>> 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;
>> +
>
>Can you do this per loop instead?  Using optimize_loop_nest_for_size_p?

Update it according to the comments.

Thanks!
-Zhenqiang

diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index f8405dd..b0e84a7 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -1931,7 +1931,8 @@ move_loop_invariants (void)
       curr_loop = loop;
       /* move_single_loop_invariants for very large loops
         is time consuming and might need a lot of memory.  */
-      if (loop->num_nodes <= (unsigned) LOOP_INVARIANT_MAX_BBS_IN_LOOP)
+      if (loop->num_nodes <= (unsigned) LOOP_INVARIANT_MAX_BBS_IN_LOOP
+         && ! optimize_loop_nest_for_size_p (loop))
        move_single_loop_invariants (loop);
     }

ChangeLog:
2012-06-28  Zhenqiang Chen <zhenqiang.c...@arm.com>

        * loop-invariant.c (move_loop_invariants): Skip
        move_single_loop_invariants when optimizing loop for size




Reply via email to