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;
 }

