From patchwork Wed Dec 21 11:59:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Revital Eres X-Patchwork-Id: 5927 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 99D29242F7 for ; Wed, 21 Dec 2011 12:00:06 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 81604A18485 for ; Wed, 21 Dec 2011 12:00:06 +0000 (UTC) Received: by eaac11 with SMTP id c11so4456542eaa.11 for ; Wed, 21 Dec 2011 04:00:06 -0800 (PST) Received: by 10.204.129.24 with SMTP id m24mr1982816bks.89.1324468806255; Wed, 21 Dec 2011 04:00:06 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs36480bkc; Wed, 21 Dec 2011 04:00:02 -0800 (PST) Received: by 10.100.237.1 with SMTP id k1mr2649789anh.28.1324468800614; Wed, 21 Dec 2011 04:00:00 -0800 (PST) Received: from mail-gx0-f178.google.com (mail-gx0-f178.google.com [209.85.161.178]) by mx.google.com with ESMTPS id v10si5707670yhi.152.2011.12.21.04.00.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Dec 2011 04:00:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.161.178 is neither permitted nor denied by best guess record for domain of revital.eres@linaro.org) client-ip=209.85.161.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.178 is neither permitted nor denied by best guess record for domain of revital.eres@linaro.org) smtp.mail=revital.eres@linaro.org Received: by ggnq4 with SMTP id q4so6459691ggn.37 for ; Wed, 21 Dec 2011 04:00:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.15.161 with SMTP id y1mr3419200igc.4.1324468799724; Wed, 21 Dec 2011 03:59:59 -0800 (PST) Received: by 10.42.197.74 with HTTP; Wed, 21 Dec 2011 03:59:59 -0800 (PST) Date: Wed, 21 Dec 2011 13:59:59 +0200 Message-ID: Subject: =?UTF-8?Q?=5BPATCH=2C_SMS=5D_Prevent_the_creation_of_reg=2Dmoves_for_n?= =?UTF-8?Q?on_allocatable_definition=E2=80=8Bs_=28re=2Dsubmission=29?= From: Revital Eres To: Ayal Zaks Cc: richard sandiford , gcc-patches@gcc.gnu.org, Patch Tracking Hello, Following Richard's comment http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01469.html attached is a new version of the patch to prevent reg-moves for non allocatable definitions. Currently testing and bootstrap on ppc64-redhat-linux, enabling SMS on loops with SC 1. OK for 4.7 once testing completes? Thanks, Revital Changelog: gcc/ * ddg.c (def_non_allocatable_p): New function. (add_cross_iteration_register_deps): Call it. testsuite/ * gcc.dg/sms-11.c: New file. Index: ddg.c =================================================================== --- ddg.c (revision 182479) +++ ddg.c (working copy) @@ -263,6 +263,23 @@ create_ddg_dep_no_link (ddg_ptr g, ddg_n add_edge_to_ddg (g, e); } +/* Return true if one of the definitions in INSN is not allocatable. + Otherwise return false. */ +static bool +def_non_allocatable_p (rtx insn) +{ + df_ref *def; + + for (def = DF_INSN_DEFS (insn); *def; def++) + { + enum machine_mode mode = GET_MODE (DF_REF_REG (*def)); + + if (!have_regs_of_mode[mode]) + return true; + } + + return false; +} /* Given a downwards exposed register def LAST_DEF (which is the last definition of that register in the bb), add inter-loop true dependences @@ -335,7 +352,8 @@ add_cross_iteration_register_deps (ddg_p if (DF_REF_ID (last_def) != DF_REF_ID (first_def) || !flag_modulo_sched_allow_regmoves || JUMP_P (use_node->insn) - || autoinc_var_is_used_p (DF_REF_INSN (last_def), use_insn)) + || autoinc_var_is_used_p (DF_REF_INSN (last_def), use_insn) + || def_non_allocatable_p (DF_REF_INSN (last_def))) create_ddg_dep_no_link (g, use_node, first_def_node, ANTI_DEP, REG_DEP, 1); Index: testsuite/gcc.dg/sms-11.c =================================================================== --- testsuite/gcc.dg/sms-11.c (revision 0) +++ testsuite/gcc.dg/sms-11.c (revision 0) @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms" } */ + +extern void abort (void); + +float out[4][4] = { 6, 6, 7, 5, 6, 7, 5, 5, 6, 4, 4, 4, 6, 2, 3, 4 }; + +void +invert (void) +{ + int i, j, k = 0, swap; + float tmp[4][4] = { 5, 6, 7, 5, 6, 7, 5, 5, 4, 4, 4, 4, 3, 2, 3, 4 }; + + for (i = 0; i < 4; i++) + { + for (j = i + 1; j < 4; j++) + if (tmp[j][i] > tmp[i][i]) + swap = j; + + if (swap != i) + tmp[i][k] = tmp[swap][k]; + } + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + if (tmp[i][j] != out[i][j]) + abort (); +} + +int +main () +{ + invert (); + return 0; +} + +/* { dg-final { cleanup-rtl-dump "sms" } } */