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: 35389 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A92C20DCC for ; Thu, 14 Aug 2014 02:56:45 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hq11sf1658289vcb.7 for ; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :x-original-sender:x-original-authentication-results:content-type; bh=DrQeh1MI+SaFWX2MfuQdAk6iFKdJe59DyUBK4A+QfIw=; b=S/SybWwX3qfFAfR6+SvG8bYL1PuZYfcjFnKhyCaj4CAKSsfGvV5qdEwaGvqlxC/zSq IkLL0SrotzsQwDartCXQ3ZwIAX2IQYMUNwe7llmu6g8UnEr51AAmbWcgVgKJ8tgGLeqN jqEde+IjbfzYe5J2NdC/x2J4OZV3aeGLNjwe1KtdVgMsZIhF24oixGDqIPkMycNtTFa8 oS+lGTHeC+gXG8+ubummjD1gRE08o0JRihfvgAYUKMOs6DRV2CNeFj/FhM19Gg16XkjO 1jDUgdHDlxQwejIUryr0gI2f31o3tpHjcgP6qoniPxNqsrzfnHDyTCcqcnY+Fx2hE5p0 iyPA== X-Gm-Message-State: ALoCoQm2k6VI7qkDo/hijXsuEaz6TKbGoeoevWDv9TYjVUq/fZ5U9FTc1rLXg+PqCCbT3FOssezc X-Received: by 10.236.227.169 with SMTP id d39mr1184469yhq.45.1407985004897; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.176 with SMTP id l45ls813558qgd.81.gmail; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) X-Received: by 10.52.61.99 with SMTP id o3mr5875157vdr.46.1407985004819; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) Received: from mail-vc0-x235.google.com (mail-vc0-x235.google.com [2607:f8b0:400c:c03::235]) by mx.google.com with ESMTPS id oj1si369533veb.11.2014.08.13.19.56.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 19:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::235 as permitted sender) client-ip=2607:f8b0:400c:c03::235; Received: by mail-vc0-f181.google.com with SMTP id lf12so753821vcb.12 for ; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) X-Received: by 10.52.83.227 with SMTP id t3mr5999690vdy.20.1407985004684; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp378685vcb; Wed, 13 Aug 2014 19:56:44 -0700 (PDT) X-Received: by 10.68.217.106 with SMTP id ox10mr1622424pbc.27.1407985003748; Wed, 13 Aug 2014 19:56:43 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ag2si2877648pbd.113.2014.08.13.19.56.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Aug 2014 19:56:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-375212-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 16770 invoked by alias); 14 Aug 2014 02:56:19 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 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) 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 X-Original-Sender: zhenqiang.chen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 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)