From patchwork Fri Jul 16 07:03:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 59071 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 5960BB6F19 for ; Fri, 16 Jul 2010 17:04:53 +1000 (EST) Received: (qmail 32557 invoked by alias); 16 Jul 2010 07:04:35 -0000 Received: (qmail 32429 invoked by uid 22791); 16 Jul 2010 07:04:34 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gw0-f47.google.com (HELO mail-gw0-f47.google.com) (74.125.83.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Jul 2010 07:04:28 +0000 Received: by gwj22 with SMTP id 22so1074524gwj.20 for ; Fri, 16 Jul 2010 00:04:26 -0700 (PDT) Received: by 10.100.201.12 with SMTP id y12mr823330anf.136.1279263866773; Fri, 16 Jul 2010 00:04:26 -0700 (PDT) Received: from napoca (cpe-70-120-196-107.austin.res.rr.com [70.120.196.107]) by mx.google.com with ESMTPS id t24sm19234436ano.32.2010.07.16.00.04.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 Jul 2010 00:04:26 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Fri, 16 Jul 2010 02:04:23 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com, Sebastian Pop Subject: [PATCH 03/12] chrec_apply should only apply to the specified variable. Date: Fri, 16 Jul 2010 02:03:54 -0500 Message-Id: <1279263843-9149-4-git-send-email-sebpop@gmail.com> In-Reply-To: <1279263843-9149-1-git-send-email-sebpop@gmail.com> References: <1279263843-9149-1-git-send-email-sebpop@gmail.com> X-IsSubscribed: yes 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 2010-07-15 Sebastian Pop * tree-chrec.c (chrec_apply): Should only apply to the specified variable. Also handle multivariate chains of recurrences that satisfy evolution_function_is_affine_p. Also handle CASE_CONVERT. --- gcc/ChangeLog.graphite | 6 ++++++ gcc/tree-chrec.c | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 7498956..e6daa32 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,11 @@ 2010-07-15 Sebastian Pop + * tree-chrec.c (chrec_apply): Should only apply to the specified + variable. Also handle multivariate chains of recurrences that + satisfy evolution_function_is_affine_p. Also handle CASE_CONVERT. + +2010-07-15 Sebastian Pop + * graphite-clast-to-gimple.c (debug_clast_name_index): Removed. (debug_clast_name_indexes_1): Removed. (debug_clast_name_indexes): Removed. diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index c92b6b9..92f8de9 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -599,23 +599,40 @@ chrec_apply (unsigned var, if (TREE_CODE (x) == INTEGER_CST && SCALAR_FLOAT_TYPE_P (type)) x = build_real_from_int_cst (type, x); - if (evolution_function_is_affine_p (chrec)) + switch (TREE_CODE (chrec)) { - /* "{a, +, b} (x)" -> "a + b*x". */ - x = chrec_convert_rhs (type, x, NULL); - res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x); - res = chrec_fold_plus (type, CHREC_LEFT (chrec), res); - } + case POLYNOMIAL_CHREC: + if (evolution_function_is_affine_p (chrec)) + { + if (CHREC_VARIABLE (chrec) != var) + return build_polynomial_chrec + (CHREC_VARIABLE (chrec), + chrec_apply (var, CHREC_LEFT (chrec), x), + chrec_apply (var, CHREC_RIGHT (chrec), x)); + + /* "{a, +, b} (x)" -> "a + b*x". */ + x = chrec_convert_rhs (type, x, NULL); + res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x); + res = chrec_fold_plus (type, CHREC_LEFT (chrec), res); + } + else if (TREE_CODE (x) == INTEGER_CST + && tree_int_cst_sgn (x) == 1) + /* testsuite/.../ssa-chrec-38.c. */ + res = chrec_evaluate (var, chrec, x, 0); + else + res = chrec_dont_know; + break; - else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC) - res = chrec; + CASE_CONVERT: + res = chrec_convert (TREE_TYPE (chrec), + chrec_apply (var, TREE_OPERAND (chrec, 0), x), + NULL); + break; - else if (TREE_CODE (x) == INTEGER_CST - && tree_int_cst_sgn (x) == 1) - /* testsuite/.../ssa-chrec-38.c. */ - res = chrec_evaluate (var, chrec, x, 0); - else - res = chrec_dont_know; + default: + res = chrec; + break; + } if (dump_file && (dump_flags & TDF_DETAILS)) {