From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22236 invoked by alias); 23 Jul 2013 17:26:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22224 invoked by uid 89); 23 Jul 2013 17:26:05 -0000 X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_40,RDNS_NONE,TW_BJ,TW_BP,TW_IB autolearn=no version=3.3.1 Received: from Unknown (HELO multi.imgtec.com) (194.200.65.239) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 23 Jul 2013 17:26:04 +0000 From: "Steve Ellcey " Date: Tue, 23 Jul 2013 17:56:00 -0000 To: , Subject: [patch, mips] Size savings for MIPS16 switch statements User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-ID: X-SEF-Processed: 7_3_0_01192__2013_07_23_18_25_57 X-SW-Source: 2013-07/txt/msg01037.txt.bz2 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 * 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"