From patchwork Tue Jul 9 22:15:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 257871 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 2E20F2C009D for ; Wed, 10 Jul 2013 08:15:22 +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 :subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:content-transfer-encoding; q=dns; s= default; b=AfKZPWfS6M3UOfdz3muAfyQWjg0ZKQBLUvtFdKpYDeyxuWyQ8IJ6J SVbdhGA7YVaI/BnojnrfjmfZ9OC8vl/J2xe8hmapM197RDRtac/UCZJa4a9IoaVV Fml+ZZZaV9rNTEL5PY903SOjbRNWSV8IL06YDkvn1Ea7zbaKiMPkQI= 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 :subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:content-transfer-encoding; s=default; bh=JA1BcVqmFV+B/kL6+AUeRwrwq2M=; b=NzLkyDIna68bgodIaNs4Ei7xuOAj g+EeNqakZBdOkWYPfzxbPEqXYXYPnezHAzcbme6cGw919DP3bkaYtHbJTtHjcVQt SXmZ2ic1limPxqwV3Ma8Nj3IrDAnv5IauTaCN08ZiLUIgcoD5kVs3dsQb+Yo2fJk 3reo09Pvf4oUop4= Received: (qmail 31042 invoked by alias); 9 Jul 2013 22:15:16 -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 31031 invoked by uid 89); 9 Jul 2013 22:15:15 -0000 X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RP_MATCHES_RCVD 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 22:15:14 +0000 Subject: Re: [patch, mips] Size optimization for MIPS From: Steve Ellcey To: Richard Sandiford CC: In-Reply-To: <87a9lv4pdo.fsf@talisman.default> References: <0107490d-b4e6-4a64-ae4c-c05f00c8ee24@BAMAIL02.ba.imgtec.org> <87a9lv4pdo.fsf@talisman.default> Date: Tue, 9 Jul 2013 15:15:09 -0700 Message-ID: <1373408109.5932.28.camel@ubuntu-sellcey> MIME-Version: 1.0 X-SEF-Processed: 7_3_0_01192__2013_07_09_23_15_12 On Tue, 2013-07-09 at 18:25 +0100, Richard Sandiford wrote: > > That was always the case though. These registers weren't enabled because > you can do operations on them. They were enabled because they should make > ideal spill space. Moves to and from these registers always take 2 bytes, > whereas stack spills take either 2 or 4 bytes (as well as being slower). > > So it sounds like the problem is that the heuristics aren't tuned properly. > Disabling the registers seems like papering over the problem rather than > fixing it. But since no-one is likely to do the work to fix the heuristics, > that isn't a good enough reason to reject the patch. Pre-LRA I don't think there was any good way to tell GCC to use a register for reloads but not for anything else. I think LRA does support this and someone here has started looking at LRA but we haven't come up with register class definitions that make LRA work better then the existing setup (particularly in terms of MIPS16 object size). Do you know if anyone else has started looking at LRA on MIPS? > Please combine this with the previous block though, since the comment here > contradicts the comment there. It would also be worth saying why you > keep $24 (for CMP and CMPI) and $25 (for SVR4 PIC). OK, I have done this (see attached new patch). > Please also run some sanity checks for -mabi=eabi and functions that > have 5+ arguments (all used) to make sure that they still work. > > Thanks, > Richard I built a MIPS GCC with newlib that could handle -mabi=eabi and ran the GCC testsuite, it all looked good. I am pretty sure the GCC testsuite has tests with 5+ arguments but I did a couple of hand tests as well and they also looked good. 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..4b5a62c 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -17199,10 +17199,16 @@ mips_conditional_register_usage (void) } if (TARGET_MIPS16) { - /* In MIPS16 mode, we permit the $t temporary registers to be used - for reload. We prohibit the unused $s registers, since they + /* In MIPS16 mode, we prohibit the unused $s registers, since they are call-saved, and saving them via a MIPS16 register would - probably waste more time than just reloading the value. */ + probably waste more time than just reloading the value. + + We permit the $t temporary registers when optimizing for speed + but not when optimizing for space because using them results in + code that is larger (but faster) then not using them. We do + allow $24 (t8) because it is used in CMP and CMPI instructions + and $25 (t9) because it is used as the SVR4 PIC register. */ + fixed_regs[18] = call_used_regs[18] = 1; fixed_regs[19] = call_used_regs[19] = 1; fixed_regs[20] = call_used_regs[20] = 1; @@ -17212,6 +17218,17 @@ mips_conditional_register_usage (void) fixed_regs[26] = call_used_regs[26] = 1; fixed_regs[27] = call_used_regs[27] = 1; fixed_regs[30] = call_used_regs[30] = 1; + 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