From patchwork Thu Aug 14 02:55:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 379785 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 842AE140097 for ; Thu, 14 Aug 2014 12:56:38 +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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=RU9eYc58kv1/HaPldRdnp13wUvRa7rddL1YFqrOUVz45Cy v0p9kx3oMkkMO5fRbs7e9H9yvHtQStlbTffUtYDGh1iYzzMPvBZVwXrZ1uDkKU7A +7JSwCAmqz5Uzg/7Zg3iJB282P6FxxDnGnxkyUtAtZABXYZVkaCGGBQGWcl5A= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=s10h4Pu2JOoY/F6dVgoW76MmsgQ=; b=s4Rrbn6c4lwxzihk+Y0Z /pXJbVqukN5+JpwYgLwDwqdB3Jy4Ee8IxFKAhHxpOt2Grk6o6GR09jlYv3SuWJCs Ul8IfZi/6oEgKRC9YTd05ZIB3UdXBuHwReZD4hE2nHxS0DQKCZK181GMgpui6dMc 0n9VaekOZNq09zZcXxyL4OI= Received: (qmail 16770 invoked by alias); 14 Aug 2014 02:56:19 -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 16515 invoked by uid 89); 14 Aug 2014 02:55:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f53.google.com Received: from mail-la0-f53.google.com (HELO mail-la0-f53.google.com) (209.85.215.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 14 Aug 2014 02:55:07 +0000 Received: by mail-la0-f53.google.com with SMTP id gl10so476717lab.26 for ; Wed, 13 Aug 2014 19:55:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=DrQeh1MI+SaFWX2MfuQdAk6iFKdJe59DyUBK4A+QfIw=; b=WLsws05vi9LopMM1Eh3WXvEoEkCCmXQVB/SE2woDe+wbGuNA/UF5nHKoRIZ/zJCjUv 0NZ/hGddne1KFj8erpJ3M2fjpiQq1z8XRi7a/w1McajI34RaD0gsf6b6GpG4vvbF2wgJ Kk+5SxppsDF6iIcNycTFUUwiOXYzrbLWI1QsD2GVoqa1p1RjSdPAMWy6TrTU/AkOZ9iy U6lWHdjJLZwvl+4j67+MK3mYDT8cUm/aUKiUzPo2LEUcZ7sOcWqYiIbCJrvStEe+l8xB NKZD6UVo24hqtfpNSa4whpZK8FdPEFeKKjiAR1JA9489qZIjH+IWGbCvG/iQPOocFbNQ jHuA== X-Gm-Message-State: ALoCoQlexWvSOzEy0l9BGDD7jCpMkx4aHMKyUNwdlBF0IwO8Km7Ny+HCmpkFSguXOSgUA1crZNNU MIME-Version: 1.0 X-Received: by 10.152.5.133 with SMTP id s5mr382582las.78.1407984903451; Wed, 13 Aug 2014 19:55:03 -0700 (PDT) Received: by 10.112.140.169 with HTTP; Wed, 13 Aug 2014 19:55:03 -0700 (PDT) Date: Thu, 14 Aug 2014 10:55:03 +0800 Message-ID: Subject: [PATCH, ira] Miss checks in split_live_ranges_for_shrink_wrap From: Zhenqiang Chen To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes Hi, Function split_live_ranges_for_shrink_wrap has code if (!flag_shrink_wrap) return false; But flag_shrink_wrap is TRUE by default when optimize > 0 even if the port does not support shrink-wrap. To make sure shrink-wrap is enabled, "HAVE_simple_return" must be defined and "HAVE_simple_return" must be TRUE. Please refer function.c and shrink-wrap.c on how shrink-wrap is enabled in thread_prologue_and_epilogue_insns. To make the check easy, the patch defines a MICRO: SUPPORT_SHRINK_WRAP_P and replace the uses in ira.c and ifcvt.c Bootstrap and no make check regression on X86-64. OK for trunk? Thanks! -Zhenqiang ChangeLog: 2014-08-14 Zhenqiang Chen * shrink-wrap.h: #define SUPPORT_SHRINK_WRAP_P. * ira.c: #include "shrink-wrap.h" (split_live_ranges_for_shrink_wrap): Use SUPPORT_SHRINK_WRAP_P. * ifcvt.c: #include "shrink-wrap.h" (dead_or_predicable): Use SUPPORT_SHRINK_WRAP_P. testsuite/ChangeLog: 2014-08-14 Zhenqiang Chen * gcc.target/arm/split-live-ranges-for-shrink-wrap.c: New test. && single_succ (new_dest) == EXIT_BLOCK_PTR_FOR_FN (cfun) @@ -4293,7 +4293,6 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb, } BITMAP_FREE (return_regs); } -#endif } no_body: diff --git a/gcc/shrink-wrap.h b/gcc/shrink-wrap.h index bccfb31..31ce2d4 100644 --- a/gcc/shrink-wrap.h +++ b/gcc/shrink-wrap.h @@ -45,6 +45,9 @@ extern edge get_unconverted_simple_return (edge, bitmap_head, extern void convert_to_simple_return (edge entry_edge, edge orig_entry_edge, bitmap_head bb_flags, rtx returnjump, vec unconverted_simple_returns); +#define SUPPORT_SHRINK_WRAP_P (flag_shrink_wrap && HAVE_simple_return) +#else +#define SUPPORT_SHRINK_WRAP_P false #endif #endif /* GCC_SHRINK_WRAP_H */ diff --git a/gcc/ira.c b/gcc/ira.c index ccc6c79..8d58b60 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -392,6 +392,7 @@ along with GCC; see the file COPYING3. If not see #include "lra.h" #include "dce.h" #include "dbgcnt.h" +#include "shrink-wrap.h" struct target_ira default_target_ira; struct target_ira_int default_target_ira_int; @@ -4775,7 +4776,7 @@ split_live_ranges_for_shrink_wrap (void) bitmap_head need_new, reachable; vec queue; - if (!flag_shrink_wrap) + if (!SUPPORT_SHRINK_WRAP_P) return false; bitmap_initialize (&need_new, 0); diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index e44c1dc..c44e1c2 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -42,6 +42,7 @@ #include "df.h" #include "vec.h" #include "dbgcnt.h" +#include "shrink-wrap.h" #ifndef HAVE_conditional_move #define HAVE_conditional_move 0 @@ -4239,14 +4240,13 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb, if (NONDEBUG_INSN_P (insn)) df_simulate_find_defs (insn, merge_set); -#ifdef HAVE_simple_return /* If shrink-wrapping, disable this optimization when test_bb is the first basic block and merge_bb exits. The idea is to not move code setting up a return register as that may clobber a register used to pass function parameters, which then must be saved in caller-saved regs. A caller-saved reg requires the prologue, killing a shrink-wrap opportunity. */ - if ((flag_shrink_wrap && HAVE_simple_return && !epilogue_completed) + if ((SUPPORT_SHRINK_WRAP_P && !epilogue_completed) && ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb == test_bb && single_succ_p (new_dest)