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: 133758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 332D5B6FA7 for ; Mon, 2 Jan 2012 00:52:03 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1326030724; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=QtNlSyjR57Zvybv4aEvAZKh27/0=; b=Mi3snNIoGhGdcZLZ0hOu6E+ihvra1FZdeIi+xKXanKEFDBqqFoJ6hjZmjgazg+ hA7dafxbW4h1s6iCCLLm2Y7IY2LjN6DyBIPRk4j3nqKXOL4NODcMDP0nBvnsVsEG GPkgt4iTfbRDzZVKsvt+gkP335bennPxig9QKm72W/Ugo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=DMuvpMrq0TELZ0wT+SSXLg9F4/PDkKxOH6h4W1w7K2Sp4ohHP8Bhsd5VClTgh6 6HbNR+ARDvpuvdFLFitiJyRyPLELS9IB4tl1WOvPBUM5xFoG4TWhIdEDYU5khjVa 66KJGxr6DKONPl0wXpfc02AKHFCcxICs1HZBDD2eCOypQ=; Received: (qmail 7762 invoked by alias); 1 Jan 2012 13:51:59 -0000 Received: (qmail 7753 invoked by uid 22791); 1 Jan 2012 13:51:58 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, TW_DD X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 01 Jan 2012 13:51:45 +0000 Received: by iakh37 with SMTP id h37so25504983iak.20 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 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk 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 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" } } */