From patchwork Sun Jan 1 13:51:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Revital Eres X-Patchwork-Id: 6014 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 318FA23E01 for ; Sun, 1 Jan 2012 13:51:48 +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 16BAAA184A6 for ; Sun, 1 Jan 2012 13:51:48 +0000 (UTC) Received: by eaac11 with SMTP id c11so14019997eaa.11 for ; Sun, 01 Jan 2012 05:51:48 -0800 (PST) Received: by 10.204.133.207 with SMTP id g15mr10242583bkt.17.1325425907808; Sun, 01 Jan 2012 05:51:47 -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 ac16cs295180bkc; Sun, 1 Jan 2012 05:51:47 -0800 (PST) Received: by 10.50.191.225 with SMTP id hb1mr53982634igc.17.1325425905500; Sun, 01 Jan 2012 05:51:45 -0800 (PST) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id w8si11051040icx.31.2012.01.01.05.51.44 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jan 2012 05:51:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of revital.eres@linaro.org) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 iagf6 with SMTP id f6so32906576iag.37 for ; Sun, 01 Jan 2012 05:51:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.40.129 with SMTP id x1mr64146479igk.4.1325425904333; Sun, 01 Jan 2012 05:51:44 -0800 (PST) Received: by 10.42.197.74 with HTTP; Sun, 1 Jan 2012 05:51:44 -0800 (PST) In-Reply-To: References: <4EF2377A.3080205@redhat.com> Date: Sun, 1 Jan 2012 15:51:44 +0200 Message-ID: Subject: Re: [PATCH, SMS] Prevent the creation of reg-moves for definitions with MODE_CC From: Revital Eres To: Ayal Zaks Cc: gcc-patches@gcc.gnu.org, Patch Tracking , richard.sandiford@linaro.org, Richard Henderson Hello, > Yes, thanks for catching this. Shouldn't we prevent creating such > regmoves for (the other case of) intra-loop anti-deps as well? Right! sorry for missing that. I added an additional check in create_ddg_dep_from_intra_loop_link. Also, thanks to Bernhard Rosenkraenzer for opening PR 879725 for that ICE in Linaro GCC DB. Currently re-testing the patch on ppc64-redhat-linux and will commit it once testing completes if that's OK . Thanks, Revital gcc/ * ddg.c (def_has_ccmode_p): New function. (add_cross_iteration_register_deps, create_ddg_dep_from_intra_loop_link): Call it. testsuite/ * gcc.dg/sms-11.c: New file. Index: ddg.c =================================================================== --- ddg.c (revision 182479) +++ ddg.c (working copy) @@ -166,6 +166,24 @@ autoinc_var_is_used_p (rtx def_insn, rtx return false; } +/* Return true if one of the definitions in INSN has MODE_CC. Otherwise + return false. */ +static bool +def_has_ccmode_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 (GET_MODE_CLASS (mode) == MODE_CC) + return true; + } + + return false; +} + /* Computes the dependence parameters (latency, distance etc.), creates a ddg_edge and adds it to the given DDG. */ static void @@ -202,6 +220,7 @@ create_ddg_dep_from_intra_loop_link (ddg whose register has multiple defs in the loop. */ if (flag_modulo_sched_allow_regmoves && (t == ANTI_DEP && dt == REG_DEP) + && !def_has_ccmode_p (dest_node->insn) && !autoinc_var_is_used_p (dest_node->insn, src_node->insn)) { rtx set; @@ -335,7 +354,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_has_ccmode_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" } } */