This is the mail archive of the gcc-patches@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]

[patch, mips] Size savings for MIPS16 switch statements


While doing some space optimization work with mips16 I found that using a
larger case threshold value could shrink the code.  I did testing on some
libraries like libpng and libjpeg as well as some test cases I wrote and
came up with 10 as the best value for space savings in mips16 mode.  I did
some testing of mips32 code as well and found that this change did not
help with that code so I restricted the change to mips16 only.

Tested on mips-mti-elf target, OK for checkin?

Steve Ellcey
sellcey@mips.com



2013-07-23  Steve Ellcey  <sellcey@mips.com>

	* config/mips/mips.c (mips_case_values_threshold): New.
	(TARGET_CASE_VALUES_THRESHOLD): Define.



diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index a3735dc..fb39f7c 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -18613,6 +18613,19 @@ mips_expand_vec_minmax (rtx target, rtx op0, rtx op1,
   x = gen_rtx_IOR (vmode, t0, t1);
   emit_insn (gen_rtx_SET (VOIDmode, target, x));
 }
+
+/* Implement `CASE_VALUES_THRESHOLD'.  */
+/* Supply the default for --param case-values-threshold=0  */
+
+unsigned int
+mips_case_values_threshold (void)
+{
+  /* In MIPS16 mode using a larger case threshold generates smaller code.  */
+  if (TARGET_MIPS16 && optimize_size)
+    return 10;
+  else
+    return default_case_values_threshold ();
+}
 
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
@@ -18844,6 +18857,9 @@ mips_expand_vec_minmax (rtx target, rtx op0, rtx op1,
 #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
 #define TARGET_VECTORIZE_VEC_PERM_CONST_OK mips_vectorize_vec_perm_const_ok
 
+#undef TARGET_CASE_VALUES_THRESHOLD
+#define TARGET_CASE_VALUES_THRESHOLD mips_case_values_threshold
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-mips.h"


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