From patchwork Tue Jul 23 17:25:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 261163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 914CD2C00A6 for ; Wed, 24 Jul 2013 03:26:13 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :date:to:subject:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=pl/Vs qpgQcLJ61+aQszLoVZwEwp3mu9O0rMGF60pr3SRpjp9Pdd4qqhoR8VJ2/dfiOC38 iJrmJkrWofb2GLm8C/WIz2S6o1oBbkC4IzgSw38zM2jsSEqyicyIsjBOOTh8X8qu ejfbYAIMQTkuvnpsnFJS7KkHT52IiLk1woYKxc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :date:to:subject:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=lARVEaBu0um 4k8btco+T+6+Yzfc=; b=gHVBt7kl0C648j4GzhrA1EYAHWQPEyiM73i0Y4LjS8a mQG2fJwElupQVl5c1++hsXJkS6pJBehAAt5eQGEJrxffxhrqjhMJs2FYG3dBZ573 7hEO9yGF9yKoaMCEgi5R+v7ad1OHfb7CGxzI3HVdTmvYzpC2Nj4QTztdDsGl5A0k = 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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 10:25:51 -0700 To: , Subject: [patch, mips] Size savings for MIPS16 switch statements User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Message-ID: X-SEF-Processed: 7_3_0_01192__2013_07_23_18_25_57 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"