From patchwork Tue Jul 9 16:29:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 257778 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 07AB32C0099 for ; Wed, 10 Jul 2013 02:29:56 +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=VM98U lbudfQwFZ+D7amaK7n5hMe6TiT8DlgXLplg+2PGX2qP++Sx2BsbWpj/M8cqccBFU 4ZMt0BjQkqPTLcB6Uqm1RVfUMPE68tumaIBYA3ay9eBIkilQZqaduL8ulVBJqbG/ Z0zNDaHhxtPVEgQIOsuzKhYJLEsMz+UCWuGF30= 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=EVfTAMuL2om zuOTfeCDTTUiVvgQ=; b=BXiWp8EuqfUqVOcOgEphAZuGIPjAhEZvx8Sfw8JIDm0 JikJsKiaIj7o83bef9aepTF02YhCLqow+9Xf8EpNx+XN+vz5srHEDetI/Btz9wvg rwrD089qWr7SKMehpqwfVpVzD+libb5QbCqlvKv4vjG0ORd2lbF/O7oApGH73WmA = Received: (qmail 20307 invoked by alias); 9 Jul 2013 16:29:50 -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 20295 invoked by uid 89); 9 Jul 2013 16:29:49 -0000 X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_BJ, TW_BP, TW_IB autolearn=ham version=3.3.1 Received: from multi.imgtec.com (HELO multi.imgtec.com) (194.200.65.239) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 09 Jul 2013 16:29:49 +0000 From: "Steve Ellcey " Date: Tue, 9 Jul 2013 09:29:17 -0700 To: , Subject: [patch, mips] Size optimization for MIPS User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Message-ID: <0107490d-b4e6-4a64-ae4c-c05f00c8ee24@BAMAIL02.ba.imgtec.org> X-SEF-Processed: 7_3_0_01192__2013_07_09_17_29_46 While doing some size measurements and optimization I found that using the t0 through t7 registers on MIPS in MIPS16 mode resulted in larger code. This is because you cannot actually do any operations on these registers in MIPS16 mode but can only move data to or from them. Compiling libraries like libjpeg and libpng with this change saved about 1% in space. I also ran coremark, the space saving there was smaller and the performance slowdown was around 3% so I made the change dependent on the optimize_size flag. I tested the change with the mips-mti-elf, running the GCC testsuite with the -mips16 and saw no regressions. OK to checkin? Steve Ellcey sellcey@mips.com Steve Ellcey * config/mips/mips.c (mips_conditional_register_usage): Do not use t[0-7] registers in MIPS16 mode when optimizing for size. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index bd1d10b..fb89aa8 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -17213,6 +17213,21 @@ mips_conditional_register_usage (void) fixed_regs[27] = call_used_regs[27] = 1; fixed_regs[30] = call_used_regs[30] = 1; + /* In MIPS16 mode using the $t registers for reload results in code + that is larger (and slightly faster) then if we do not use them so + if optimizing for size, do not use them. */ + if (optimize_size) + { + fixed_regs[8] = call_used_regs[8] = 1; + fixed_regs[9] = call_used_regs[9] = 1; + fixed_regs[10] = call_used_regs[10] = 1; + fixed_regs[11] = call_used_regs[11] = 1; + fixed_regs[12] = call_used_regs[12] = 1; + fixed_regs[13] = call_used_regs[13] = 1; + fixed_regs[14] = call_used_regs[14] = 1; + fixed_regs[15] = call_used_regs[15] = 1; + } + /* Do not allow HI and LO to be treated as register operands. There are no MTHI or MTLO instructions (or any real need for them) and one-way registers cannot easily be reloaded. */