From patchwork Mon Jun 23 02:53:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 32316 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 414A72055C for ; Mon, 23 Jun 2014 02:53:49 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id uz6sf20160898obc.0 for ; Sun, 22 Jun 2014 19:53:48 -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:cc :x-original-sender:x-original-authentication-results:content-type; bh=RBi4Dn3F1/Op18dvlKUDlGci2IjIelm365/9EoZ0WY0=; b=Z9qDVkd+/XCmgusC0ZN8z2fWDikqW9vhqvJfVflQZO6zbIn+y1jEqoJ947PnsLF7aM wH6AqpfalL4BNQA1TWx9MbBeCzXQe6TuLhWWy4S5tb/Hh5z7Rs5CcYj/MST4qbng8ABt OfbsKEYxJTl1ZQ6Lpdwk2geb/JZ9n9CR0KvQBdhECotbnBuyo92W4bBAlNrMwjQ3kbRj tww5KPUCzmrnVbcg87HQNy3wkN8HcRE7wFdEhhbxzHMziIgKdbnRMgNLluamiyKLXO9M Zjc9gqH1RPSZyNJdwnepBHmt9EYxSKc6HvwNK3LviRx20mUTEYDAbbbwJh9E/DCKC0zs 2siA== X-Gm-Message-State: ALoCoQn/Hf/LnJl8fy3u26+Cc1dKEqbZ+KUjwCimke+ixJu92RtZXXf8RqM2F1KQRZNq+J+Qu/Ek X-Received: by 10.182.249.115 with SMTP id yt19mr8800686obc.25.1403492028630; Sun, 22 Jun 2014 19:53:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.100 with SMTP id f91ls1825134qge.65.gmail; Sun, 22 Jun 2014 19:53:48 -0700 (PDT) X-Received: by 10.52.244.138 with SMTP id xg10mr610568vdc.40.1403492028553; Sun, 22 Jun 2014 19:53:48 -0700 (PDT) Received: from mail-vc0-x22a.google.com (mail-vc0-x22a.google.com [2607:f8b0:400c:c03::22a]) by mx.google.com with ESMTPS id kz4si8251267vdb.74.2014.06.22.19.53.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Jun 2014 19:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22a as permitted sender) client-ip=2607:f8b0:400c:c03::22a; Received: by mail-vc0-f170.google.com with SMTP id hy10so5421696vcb.1 for ; Sun, 22 Jun 2014 19:53:48 -0700 (PDT) X-Received: by 10.52.26.237 with SMTP id o13mr13913707vdg.1.1403492028272; Sun, 22 Jun 2014 19:53:48 -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 tc5csp101089vcb; Sun, 22 Jun 2014 19:53:47 -0700 (PDT) X-Received: by 10.66.97.67 with SMTP id dy3mr24911704pab.24.1403492027392; Sun, 22 Jun 2014 19:53:47 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id qn15si19823007pab.176.2014.06.22.19.53.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jun 2014 19:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-370780-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 18500 invoked by alias); 23 Jun 2014 02:53:34 -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 18487 invoked by uid 89); 23 Jun 2014 02:53:32 -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-f45.google.com Received: from mail-la0-f45.google.com (HELO mail-la0-f45.google.com) (209.85.215.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 23 Jun 2014 02:53:31 +0000 Received: by mail-la0-f45.google.com with SMTP id hr17so3721326lab.4 for ; Sun, 22 Jun 2014 19:53:27 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.5.230 with SMTP id v6mr14830329lav.33.1403492007522; Sun, 22 Jun 2014 19:53:27 -0700 (PDT) Received: by 10.112.13.36 with HTTP; Sun, 22 Jun 2014 19:53:27 -0700 (PDT) Date: Mon, 23 Jun 2014 10:53:27 +0800 Message-ID: Subject: [Committed] [PATCH, loop2_invariant] Pre-check invariants From: Zhenqiang Chen To: Jeff Law Cc: Steven Bosscher , "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::22a 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 On 18 June 2014 05:32, Jeff Law wrote: > On 06/11/14 03:35, Zhenqiang Chen wrote: >> >> >> Thanks for the comments. df_live seams redundant. >> >> With flag_ira_loop_pressure, the pass will call df_analyze () at the >> beginning, which can make sure all the DF info are correct. >> >> Can we guarantee all DF_... correct without df_analyze ()? > > They should be fine in this context. > > > >> +/* Pre-check candidate DEST to skip the one which can not make a valid >> insn >> + during move_invariant_reg. SIMPlE is to skip HARD_REGISTER. */ > > s/SIMPlE/SIMPLE/ > > > >> + { >> + /* Multi definitions at this stage, most likely are due to >> + instruction constrain, which requires both read and >> write > > s/constrain/constraints/ > > Though that doesn't make sense. Constraints don't come into play until much > later in the pipeline. Certainly there's been code in the expanders and > elsewhere to try and make the code we generate more acceptable to 2-address > targets and that's probably what you're really running into. I think the > code is fine, but that you need to improve the comment. > > ISTM that if your primary focus is to filter out read/write operands, then > just say that and ignore the constraints or other mechanisms by which we got > a read/write pseudo. > > So I think with those two small comment changes, this patch is OK for the > trunk. Please post the final version for archival purposes before checking > it in. Thanks. Patch was installed @r211885 with the two comment changes and one more change to use FOR_EACH_INSN_INFO_DEF other than for (def_rec = DF_INSN_INFO_DEFS (insn_info); *def_rec; def_rec++) Bootstrap and no make check regression on X86-64. Index: gcc/loop-invariant.c =================================================================== --- gcc/loop-invariant.c (revision 211832) +++ gcc/loop-invariant.c (working copy) @@ -839,6 +839,39 @@ return true; } +/* Pre-check candidate DEST to skip the one which can not make a valid insn + during move_invariant_reg. SIMPLE is to skip HARD_REGISTER. */ +static bool +pre_check_invariant_p (bool simple, rtx dest) +{ + if (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_EACH_INSN_INFO_DEF (def_rec, insn_info) + if (DF_REF_REGNO (def_rec) == i) + { + /* Multi definitions at this stage, most likely are due to + instruction constraints, 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 false; + } + } + } + return true; +} + /* Finds invariant in INSN. ALWAYS_REACHED is true if the insn is always executed. ALWAYS_EXECUTED is true if the insn is always executed, unless the program ends due to a function call. */ @@ -868,7 +901,8 @@ || HARD_REGISTER_P (dest)) simple = false; - if (!may_assign_reg_p (SET_DEST (set)) + if (!may_assign_reg_p (dest) + || !pre_check_invariant_p (simple, dest) || !check_maybe_invariant (SET_SRC (set))) return;