From patchwork Wed Nov 3 21:40:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 70074 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 A71B6B70AF for ; Thu, 4 Nov 2010 08:40:18 +1100 (EST) Received: (qmail 16784 invoked by alias); 3 Nov 2010 21:40:16 -0000 Received: (qmail 16645 invoked by uid 22791); 3 Nov 2010 21:40:15 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-px0-f175.google.com (HELO mail-px0-f175.google.com) (209.85.212.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Nov 2010 21:40:10 +0000 Received: by pxi2 with SMTP id 2so50825pxi.20 for ; Wed, 03 Nov 2010 14:40:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.166.7 with SMTP id o7mr2504126wfe.428.1288820408690; Wed, 03 Nov 2010 14:40:08 -0700 (PDT) Received: by 10.143.167.14 with HTTP; Wed, 3 Nov 2010 14:40:08 -0700 (PDT) In-Reply-To: <87bp66gkzc.fsf@firetop.home> References: <87bp66gkzc.fsf@firetop.home> Date: Wed, 3 Nov 2010 22:40:08 +0100 Message-ID: Subject: Re: [PATCH, MIPS]: Remove ugly hack from "call_internal" splitter From: Uros Bizjak To: Uros Bizjak , gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com 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 On Wed, Nov 3, 2010 at 10:23 PM, Richard Sandiford wrote: > Uros Bizjak writes: >> Hello! >> >> We should simply use curr_insn instead of an ugly hack. >> >> 2010-11-02  Uros Bizjak   >> >>       * config/mips/mips.md (call_internal): Pass curr_insn to >>       mips_split_call. >> >> Compile tested on x86_64-pc-linux-gnu for mips-elf cross. > > Please do the call splitters too.  OK with that change if it > passes regression testing. In addition to other call splitters, I noticed that mips_split_call copies CALL_INSN_FUNCTION_USAGE to splitted call_insn pattern. This is not necessary, since try_split will do that automatically (se emit-rtl.c, around line 3459). 2010-11-03 Uros Bizjak * config/mips/mips.md (call_internal): Pass curr_insn to mips_split_call. (call_internal_direct): Ditto. (call_value_internal): Ditto. (call_value_internal_direct): Ditto. (call_value_multiple_internal): Ditto. * config/mips/mips.c (mips_split_call): Do not copy CALL_INSN_FUNCTION_USAGE here. Attached patch was tested by building a cross to mips-elf. Unfortunatelly, I have no access to real mips target, so I would like to ask somebody if can do a regression test of attached patch. Uros. Index: gcc/config/mips/mips.md =================================================================== --- gcc/config/mips/mips.md (revision 166247) +++ gcc/config/mips/mips.md (working copy) @@ -6033,18 +6033,16 @@ ;; But once we generate the separate insns, it becomes obvious that ;; $gp is not live on entry to the call. ;; -;; ??? The operands[2] = insn check is a hack to make the original insn -;; available to the splitter. (define_insn_and_split "call_internal" [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S")) (match_operand 1 "" "")) (clobber (reg:SI RETURN_ADDR_REGNUM))] "" { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 0, 1); } - "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)" + "reload_completed && TARGET_SPLIT_CALLS" [(const_int 0)] { - mips_split_call (operands[2], gen_call_split (operands[0], operands[1])); + mips_split_call (curr_insn, gen_call_split (operands[0], operands[1])); DONE; } [(set_attr "jal" "indirect,direct")]) @@ -6069,10 +6067,10 @@ (clobber (reg:SI RETURN_ADDR_REGNUM))] "" { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 0, -1); } - "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)" + "reload_completed && TARGET_SPLIT_CALLS" [(const_int 0)] { - mips_split_call (operands[2], + mips_split_call (curr_insn, gen_call_direct_split (operands[0], operands[1])); DONE; } @@ -6108,10 +6106,10 @@ (clobber (reg:SI RETURN_ADDR_REGNUM))] "" { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1, 2); } - "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)" + "reload_completed && TARGET_SPLIT_CALLS" [(const_int 0)] { - mips_split_call (operands[3], + mips_split_call (curr_insn, gen_call_value_split (operands[0], operands[1], operands[2])); DONE; @@ -6137,10 +6135,10 @@ (clobber (reg:SI RETURN_ADDR_REGNUM))] "" { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1, -1); } - "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)" + "reload_completed && TARGET_SPLIT_CALLS" [(const_int 0)] { - mips_split_call (operands[3], + mips_split_call (curr_insn, gen_call_value_direct_split (operands[0], operands[1], operands[2])); DONE; @@ -6169,10 +6167,10 @@ (clobber (reg:SI RETURN_ADDR_REGNUM))] "" { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1, 2); } - "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)" + "reload_completed && TARGET_SPLIT_CALLS" [(const_int 0)] { - mips_split_call (operands[4], + mips_split_call (curr_insn, gen_call_value_multiple_split (operands[0], operands[1], operands[2], operands[3])); DONE; Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c (revision 166247) +++ gcc/config/mips/mips.c (working copy) @@ -6519,8 +6519,6 @@ mips_split_call (rtx insn, rtx call_patt rtx new_insn; new_insn = emit_call_insn (call_pattern); - CALL_INSN_FUNCTION_USAGE (new_insn) - = copy_rtx (CALL_INSN_FUNCTION_USAGE (insn)); if (!find_reg_note (insn, REG_NORETURN, 0)) /* Pick a temporary register that is suitable for both MIPS16 and non-MIPS16 code. $4 and $5 are used for returning complex double