From patchwork Tue Jun 10 09:55:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 31612 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9E0B62054B for ; Tue, 10 Jun 2014 09:55:54 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kq14sf1892082pab.8 for ; Tue, 10 Jun 2014 02:55:53 -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=ML9/qWc2Y3Vj/qKVMJ7GTLn2xsmEUJmi8/m9+GI1jZQ=; b=KOcGgZiwW16jnLFgEhCBp5XZvchYP3FXtltWOgD78NckQiaYmj3b00b7UU6NdIe+JS 23/FXvyAo9BhS8F96hT3uLchNSb/aRsjCZW/KEqlX3W6SPU/dpXUboCbkS3cZOus4Je1 +xdcX/IdfOOONHB98wj+S9kbthpcbxfood83ASzG88OweEgQSQ8rqusXoqC2IZVwXiYn 5pIGtGKuWhOLs7Pf0aWJwhD7Hfa7dQXQZ/n7+E5PwM3Lj54a2h4FChm6HDg14hI2Wgb7 lpReawGCw5oNq9wPA4TpN5tiscfvhLts0qSYZg3NC8mU7hVbI/YN8amTAiaBrvQXdcgX /YYA== X-Gm-Message-State: ALoCoQliH7gknvyQRbIijmcyFJ6VW/sGmf/vW/peAcKlFRsUGXus8Q1WyrhbKqQf5R/2BOD6ejr4 X-Received: by 10.66.65.142 with SMTP id x14mr2071793pas.14.1402394153866; Tue, 10 Jun 2014 02:55:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.165 with SMTP id d34ls2047613qgd.25.gmail; Tue, 10 Jun 2014 02:55:53 -0700 (PDT) X-Received: by 10.52.5.129 with SMTP id s1mr26678272vds.31.1402394153672; Tue, 10 Jun 2014 02:55:53 -0700 (PDT) Received: from mail-vc0-x229.google.com (mail-vc0-x229.google.com [2607:f8b0:400c:c03::229]) by mx.google.com with ESMTPS id fs13si12880977vdb.23.2014.06.10.02.55.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 02:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::229 as permitted sender) client-ip=2607:f8b0:400c:c03::229; Received: by mail-vc0-f169.google.com with SMTP id la4so7627105vcb.14 for ; Tue, 10 Jun 2014 02:55:53 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr31053992vck.29.1402394153441; Tue, 10 Jun 2014 02:55:53 -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.54.6 with SMTP id vs6csp212456vcb; Tue, 10 Jun 2014 02:55:52 -0700 (PDT) X-Received: by 10.66.150.40 with SMTP id uf8mr4285861pab.89.1402394152417; Tue, 10 Jun 2014 02:55:52 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u2si33736384pbz.202.2014.06.10.02.55.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jun 2014 02:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-369869-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 19467 invoked by alias); 10 Jun 2014 09:55:40 -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 19457 invoked by uid 89); 10 Jun 2014 09:55:40 -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-f50.google.com Received: from mail-la0-f50.google.com (HELO mail-la0-f50.google.com) (209.85.215.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 10 Jun 2014 09:55:39 +0000 Received: by mail-la0-f50.google.com with SMTP id b8so3821615lan.9 for ; Tue, 10 Jun 2014 02:55:35 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.13.137 with SMTP id h9mr20467013lbc.33.1402394135525; Tue, 10 Jun 2014 02:55:35 -0700 (PDT) Received: by 10.112.13.36 with HTTP; Tue, 10 Jun 2014 02:55:35 -0700 (PDT) Date: Tue, 10 Jun 2014 17:55:35 +0800 Message-ID: Subject: [PATCH, loop2_invariant] Pre-check invariants 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::229 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, During tests, I found some invariants could not be replaced at the last stage. If we can identify such invariants earlier, we can skip them and give the chance to other invariants. So the patch pre-checks candidates to skip the one which can not make a valid insn during replacement in move_invariant_reg. Bootstrap and no make check regression on X86-64. Bootstrap and no make check regression on X86-64 with flag_ira_loop_pressure = true. OK for trunk? Thanks! -Zhenqiang ChangeLog: 2014-06-10 Zhenqiang Chen * loop-invariant.c (find_invariant_insn): Skip invariants, which can not make a valid insn during replacement in move_invariant_reg. return; diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index c43206a..7be4b29 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -881,6 +881,35 @@ find_invariant_insn (rtx insn, bool always_reached, bool always_executed) || HARD_REGISTER_P (dest)) simple = false; + /* Pre-check candidate to skip the one which can not make a valid insn + during move_invariant_reg. */ + if (flag_ira_loop_pressure && df_live && simple + && REG_P (dest) && DF_REG_DEF_COUNT (REGNO (dest)) > 1) + { + df_ref use; + rtx ref; + unsigned int i = REGNO (dest); + struct df_insn_info *insn_info; + df_ref *def_rec; + + for (use = DF_REG_USE_CHAIN (i); use; use = DF_REF_NEXT_REG (use)) + { + ref = DF_REF_INSN (use); + insn_info = DF_INSN_INFO_GET (ref); + + for (def_rec = DF_INSN_INFO_DEFS (insn_info); *def_rec; def_rec++) + if (DF_REF_REGNO (*def_rec) == i) + { + /* Multi definitions at this stage, most likely are due to + instruction constrain, which requires both read and write + on the same register. Since move_invariant_reg is not + powerful enough to handle such cases, just ignore the INV + and leave the chance to others. */ + return; + } + } + } + if (!may_assign_reg_p (SET_DEST (set)) || !check_maybe_invariant (SET_SRC (set)))