From patchwork Wed Nov 14 19:02:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 198980 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]) by ozlabs.org (Postfix) with SMTP id B7E162C00A6 for ; Thu, 15 Nov 2012 06:02:25 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353524546; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:Date:To:CC:Subject:User-Agent: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=D7SbSFmsAb4FbIuoPDg7 c6BYMLQ=; b=PG48RvF/mqKzPFsEXjamdDMqvD4ikNw04YiQQbmckTyEOGbLUuPH a15o4JU/NRskkQ4Cy5w/RLW5mj5NPfMv3x3wxLgQF6YwNQDBNAm7W6eVcOkj+Z6I 8UujWE/3zXeY6MwIq3xWi6VfvfLm0e2NEUQq9SnCjuPCUttVapH6VvA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-M-MSG:Received:Received:Received:From:Date:To:CC:Subject:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID:X-EMS-Proccessed:X-EMS-STAMP:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Yx9zZNFG3TMTCpr9tk1ml9v4gjldkrNiAPBthw7+7JU/x6wakKxlNxoZKCVo2l 17fobrRm8qI8qByPSR92MODuRxqmXvzb1Z0Otx43OoKoF34npK9CZIqvS0aLubpJ yxyqRnf7A5ZFBPICN1c1YO/nk0CH6XdtzLm54TeSKFcCA=; Received: (qmail 16313 invoked by alias); 14 Nov 2012 19:02:21 -0000 Received: (qmail 16303 invoked by uid 22791); 14 Nov 2012 19:02:20 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from dns1.mips.com (HELO dns1.mips.com) (12.201.5.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Nov 2012 19:02:14 +0000 Received: from mailgate1.mips.com (mailgate1.mips.com [12.201.5.111]) by dns1.mips.com (8.13.8/8.13.8) with ESMTP id qAEJ2Dqh031580; Wed, 14 Nov 2012 11:02:13 -0800 X-M-MSG: Received: from exchdb01.mips.com (unknown [192.168.36.84]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mailgate1.mips.com (Postfix) with ESMTP id 2E8D6364600; Wed, 14 Nov 2012 11:02:10 -0800 (PST) Received: from ubuntu-sellcey.mips.com (192.168.65.53) by exchhub01.mips.com (192.168.36.84) with Microsoft SMTP Server id 14.1.270.1; Wed, 14 Nov 2012 11:02:06 -0800 Received: by ubuntu-sellcey.mips.com (sSMTP sendmail emulation); Wed, 14 Nov 2012 11:02:06 -0800 From: "Steve Ellcey " Date: Wed, 14 Nov 2012 11:02:06 -0800 To: CC: Subject: [patch] Performance patch for MIPS conditional move in expr.c User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Message-ID: <27d19005-b82d-4ecc-a81e-14208937ce0f@EXCHHUB01.MIPS.com> X-EMS-Proccessed: 6LP3oGfGVdcdb8o1aBnt6w== X-EMS-STAMP: /O/WvzNITVmsP51gojsy0Q== 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 Back in August of 2011, Richard Biener made a change affecting COND_EXPRs (r178408). As a result of that change the GCC MIPS compiler that used to promote HImode variables to SImode and then put out SImode variables and assignments for the conditional move (MIPS doesn't support HImode conditional moves) started putting out HImode variables and assignments and the resulting code is slower then it was. The code that used to look like this: (insn 23 22 24 3 (set (reg/v:SI 231 [ a2+-2 ]) (zero_extend:SI (subreg:HI (reg:SI 320) 2))) x.c:11 -1 (nil)) (insn 27 26 28 3 (set (reg/v:SI 233 [ a2+-2 ]) (zero_extend:SI (subreg:HI (reg:SI 323) 2))) x.c:12 -1 (nil)) IF () (insn 30 241 31 4 (set (reg:SI 324) (reg/v:SI 231 [ a2+-2 ])) -1 (nil)) ELSE (insn 34 242 35 5 (set (reg:SI 324) (reg/v:SI 233 [ a2+-2 ])) -1 (nil)) (insn 36 243 37 6 (set (reg/v:SI 234 [ a2+-2 ]) (reg:SI 324)) -1 (nil)) started outputting HI assignments instead: (insn 23 22 24 3 (set (reg/v:SI 231 [ a2+-2 ]) (zero_extend:SI (subreg:HI (reg:SI 320) 2))) x.c:11 -1 (nil)) (insn 27 26 28 3 (set (reg/v:SI 233 [ a2+-2 ]) (zero_extend:SI (subreg:HI (reg:SI 323) 2))) x.c:12 -1 (nil)) IF () (insn 30 241 31 4 (set (reg:HI 324) (subreg/s/u:HI (reg/v:SI 231 [ a2+-2 ]) 2)) -1 (nil)) ELSE (insn 34 242 35 5 (set (reg:HI 324) (subreg/s/u:HI (reg/v:SI 233 [ a2+-2 ]) 2)) -1 (nil)) (insn 36 243 37 6 (set (reg/v:SI 234 [ a2+-2 ]) (zero_extend:SI (reg:HI 324))) -1 (nil)) This resulted in an extra 'andi REG,REG,0xffff' instruction to implement the final zero_extend instruction and that slowed the code down. This patch restores the previous behaviour by modifying expand_cond_expr_using_cmove so that when we need to promote the mode in order to do a conditional move we use that promoted mode in the temp that we are creating for the conditional move. Tested on mips-mti-elf with no regressions. OK for checkin? Steve Ellcey sellcey@mips.com 2012-11-14 Steve Ellcey * expr.c (expand_cond_expr_using_cmove): Use promoted mode for temp. diff --git a/gcc/expr.c b/gcc/expr.c index cbf3a40..b1b83d0 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7840,15 +7840,17 @@ expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED, int unsignedp = TYPE_UNSIGNED (type); enum machine_mode mode = TYPE_MODE (type); - temp = assign_temp (type, 0, 1); - /* If we cannot do a conditional move on the mode, try doing it with the promoted mode. */ if (!can_conditionally_move_p (mode)) - mode = promote_mode (type, mode, &unsignedp); - - if (!can_conditionally_move_p (mode)) - return NULL_RTX; + { + mode = promote_mode (type, mode, &unsignedp); + if (!can_conditionally_move_p (mode)) + return NULL_RTX; + temp = assign_temp (type, 0, 0); /* Use promoted mode for temp. */ + } + else + temp = assign_temp (type, 0, 1); start_sequence (); expand_operands (treeop1, treeop2,