From patchwork Mon Jul 23 18:08:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 172733 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 7A3BC2C0346 for ; Tue, 24 Jul 2012 04:08:58 +1000 (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=1343671739; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=SIPu8i6 41QyBaJabBibd9i1XHds=; b=Uvzwdll4eXvb2oTEoPbkce43k7hASKmNUqSTTGg YF2cJJNGH36A2JSMZ/hJ+PIRcPd7G6CgqEDVeUzxkl8g4IioXu7MvQqnocv2xa1K Ug056rRgbaswwEnqJGWjW+sKqHv0CsMElNMDMDnuULhRj+6+S6qTBlMvKbBvEzAg +HAw= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=o2KSEDFYx5TiekAnycMsaxU/sbrpL4R8oc80AYm8GVHk5fCj3d5LmnO48Rljrx TgogMQIa3YdsfW0M/84Q9kp7f7j/Ex8T4PxIusJsMyCHqnZb30fR7draUyVNd186 v8BV975TdCn/BdxCbYg3KlcX7UYlcn40OCRgWJvfn7fko=; Received: (qmail 31623 invoked by alias); 23 Jul 2012 18:08:54 -0000 Received: (qmail 31615 invoked by uid 22791); 23 Jul 2012 18:08:53 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jul 2012 18:08:38 +0000 Received: by obcva7 with SMTP id va7so12025660obc.20 for ; Mon, 23 Jul 2012 11:08:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.217.38 with SMTP id ov6mr19248301obc.33.1343066917690; Mon, 23 Jul 2012 11:08:37 -0700 (PDT) Received: by 10.76.112.44 with HTTP; Mon, 23 Jul 2012 11:08:37 -0700 (PDT) Date: Mon, 23 Jul 2012 20:08:37 +0200 Message-ID: Subject: [PATCH, i386]: Make ix86_lea_outperform static and cleanup LEA split helpers From: Uros Bizjak To: gcc-patches@gcc.gnu.org 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 Hello! No functional changes. 2012-07-23 Uros Bizjak * config/i386/i386-protos.c (ix86_lea_outperforms): Remove prototype. * config/i386/i386.c (ix86_lea_outperforms): Make static. Make split_cost argument signed. (ix86_avoid_lea_for_add): Cleanup. (ix86_use_lea_for_mov): Use INVALID_REGNUM instead of -1. (ix86_avoid_lea_for_addr): Ditto. Make split_cost signed. Use gen_lowpart instead of gen_rtx_SUBREG. Cleanup. Tested on x86_64-pc-linux-gnu {,-m32} configure with --with-arch=core2 --with-cpu=atom, committed to mainline SVN. Uros. Index: i386.c =================================================================== --- i386.c (revision 189787) +++ i386.c (working copy) @@ -16805,9 +16805,9 @@ distance_agu_use (unsigned int regno0, rtx insn) over a sequence of instructions. Instructions sequence has SPLIT_COST cycles higher latency than lea latency. */ -bool +static bool ix86_lea_outperforms (rtx insn, unsigned int regno0, unsigned int regno1, - unsigned int regno2, unsigned int split_cost) + unsigned int regno2, int split_cost) { int dist_define, dist_use; @@ -16880,9 +16880,7 @@ ix86_ok_to_clobber_flags (rtx insn) bool ix86_avoid_lea_for_add (rtx insn, rtx operands[]) { - unsigned int regno0 = true_regnum (operands[0]); - unsigned int regno1 = true_regnum (operands[1]); - unsigned int regno2 = true_regnum (operands[2]); + unsigned int regno0, regno1, regno2; /* Check if we need to optimize. */ if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun)) @@ -16892,6 +16890,10 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[]) if (!ix86_ok_to_clobber_flags(insn)) return false; + regno0 = true_regnum (operands[0]); + regno1 = true_regnum (operands[1]); + regno2 = true_regnum (operands[2]); + /* We need to split only adds with non destructive destination operand. */ if (regno0 == regno1 || regno0 == regno2) @@ -16906,8 +16908,7 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[]) bool ix86_use_lea_for_mov (rtx insn, rtx operands[]) { - unsigned int regno0; - unsigned int regno1; + unsigned int regno0, regno1; /* Check if we need to optimize. */ if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun)) @@ -16920,7 +16921,7 @@ ix86_use_lea_for_mov (rtx insn, rtx operands[]) regno0 = true_regnum (operands[0]); regno1 = true_regnum (operands[1]); - return ix86_lea_outperforms (insn, regno0, regno1, -1, 0); + return ix86_lea_outperforms (insn, regno0, regno1, INVALID_REGNUM, 0); } /* Return true if we need to split lea into a sequence of @@ -16929,10 +16930,8 @@ ix86_use_lea_for_mov (rtx insn, rtx operands[]) bool ix86_avoid_lea_for_addr (rtx insn, rtx operands[]) { - unsigned int regno0 = true_regnum (operands[0]) ; - unsigned int regno1 = -1; - unsigned int regno2 = -1; - unsigned int split_cost = 0; + unsigned int regno0, regno1, regno2; + int split_cost; struct ix86_address parts; int ok; @@ -16957,11 +16956,17 @@ ix86_avoid_lea_for_addr (rtx insn, rtx operands[]) if (parts.disp && flag_pic && !LEGITIMATE_PIC_OPERAND_P (parts.disp)) return false; + regno0 = true_regnum (operands[0]) ; + regno1 = INVALID_REGNUM; + regno2 = INVALID_REGNUM; + if (parts.base) regno1 = true_regnum (parts.base); if (parts.index) regno2 = true_regnum (parts.index); + split_cost = 0; + /* Compute how many cycles we will add to execution time if split lea into a sequence of instructions. */ if (parts.base || parts.index) @@ -17021,27 +17026,31 @@ ix86_emit_binop (enum rtx_code code, enum machine_ extern void ix86_split_lea_for_addr (rtx operands[], enum machine_mode mode) { - unsigned int regno0 = true_regnum (operands[0]) ; - unsigned int regno1 = INVALID_REGNUM; - unsigned int regno2 = INVALID_REGNUM; + unsigned int regno0, regno1, regno2; struct ix86_address parts; - rtx tmp; + rtx target, tmp; int ok, adds; ok = ix86_decompose_address (operands[1], &parts); gcc_assert (ok); + target = operands[0]; + + regno0 = true_regnum (target); + regno1 = INVALID_REGNUM; + regno2 = INVALID_REGNUM; + if (parts.base) { if (GET_MODE (parts.base) != mode) - parts.base = gen_rtx_SUBREG (mode, parts.base, 0); + parts.base = gen_lowpart (mode, parts.base); regno1 = true_regnum (parts.base); } if (parts.index) { if (GET_MODE (parts.index) != mode) - parts.index = gen_rtx_SUBREG (mode, parts.index, 0); + parts.index = gen_lowpart (mode, parts.index); regno2 = true_regnum (parts.index); } @@ -17057,41 +17066,41 @@ ix86_split_lea_for_addr (rtx operands[], enum mach gcc_assert (regno2 != regno0); for (adds = parts.scale; adds > 0; adds--) - ix86_emit_binop (PLUS, mode, operands[0], parts.index); + ix86_emit_binop (PLUS, mode, target, parts.index); } else { /* r1 = r2 + r3 * C case. Need to move r3 into r1. */ if (regno0 != regno2) - emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.index)); + emit_insn (gen_rtx_SET (VOIDmode, target, parts.index)); /* Use shift for scaling. */ - ix86_emit_binop (ASHIFT, mode, operands[0], + ix86_emit_binop (ASHIFT, mode, target, GEN_INT (exact_log2 (parts.scale))); if (parts.base) - ix86_emit_binop (PLUS, mode, operands[0], parts.base); + ix86_emit_binop (PLUS, mode, target, parts.base); if (parts.disp && parts.disp != const0_rtx) - ix86_emit_binop (PLUS, mode, operands[0], parts.disp); + ix86_emit_binop (PLUS, mode, target, parts.disp); } } else if (!parts.base && !parts.index) { gcc_assert(parts.disp); - emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.disp)); + emit_insn (gen_rtx_SET (VOIDmode, target, parts.disp)); } else { if (!parts.base) { if (regno0 != regno2) - emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.index)); + emit_insn (gen_rtx_SET (VOIDmode, target, parts.index)); } else if (!parts.index) { if (regno0 != regno1) - emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.base)); + emit_insn (gen_rtx_SET (VOIDmode, target, parts.base)); } else { @@ -17101,15 +17110,15 @@ ix86_split_lea_for_addr (rtx operands[], enum mach tmp = parts.base; else { - emit_insn (gen_rtx_SET (VOIDmode, operands[0], parts.base)); + emit_insn (gen_rtx_SET (VOIDmode, target, parts.base)); tmp = parts.index; } - ix86_emit_binop (PLUS, mode, operands[0], tmp); + ix86_emit_binop (PLUS, mode, target, tmp); } if (parts.disp && parts.disp != const0_rtx) - ix86_emit_binop (PLUS, mode, operands[0], parts.disp); + ix86_emit_binop (PLUS, mode, target, parts.disp); } } Index: i386-protos.h =================================================================== --- i386-protos.h (revision 189786) +++ i386-protos.h (working copy) @@ -92,8 +92,6 @@ extern void ix86_fixup_binary_operands_no_copy (en extern void ix86_expand_binary_operator (enum rtx_code, enum machine_mode, rtx[]); extern bool ix86_binary_operator_ok (enum rtx_code, enum machine_mode, rtx[]); -extern bool ix86_lea_outperforms (rtx, unsigned int, unsigned int, - unsigned int, unsigned int); extern bool ix86_avoid_lea_for_add (rtx, rtx[]); extern bool ix86_use_lea_for_mov (rtx, rtx[]); extern bool ix86_avoid_lea_for_addr (rtx, rtx[]);