From patchwork Sat Aug 28 09:06:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 62900 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 091ECB711D for ; Sat, 28 Aug 2010 19:07:12 +1000 (EST) Received: (qmail 30450 invoked by alias); 28 Aug 2010 09:07:07 -0000 Received: (qmail 30431 invoked by uid 22791); 28 Aug 2010 09:07:05 -0000 X-SWARE-Spam-Status: No, hits=2.3 required=5.0 tests=BAYES_50, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp5.netcologne.de (HELO smtp5.netcologne.de) (194.8.194.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 28 Aug 2010 09:06:59 +0000 Received: from [192.168.0.196] (xdsl-84-44-140-196.netcologne.de [84.44.140.196]) by smtp5.netcologne.de (Postfix) with ESMTP id D363240CC66; Sat, 28 Aug 2010 11:06:56 +0200 (CEST) Subject: Re: [patch, fortran] Further dependency improvements From: Thomas Koenig To: Daniel Kraft Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org In-Reply-To: <4C78C94B.7010307@domob.eu> References: <1282983112.3506.1.camel@linux-fd1f.site> <4C78C94B.7010307@domob.eu> Date: Sat, 28 Aug 2010 11:06:56 +0200 Message-ID: <1282986416.3506.19.camel@linux-fd1f.site> Mime-Version: 1.0 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 Hi Daniel, > I think that we introduced CLASS_PURE / CLASS_IMPURE for intrinsics > lately -- and would suggest to use that information instead of > duplicating the list here. Although I do not completely remember > whether that is already set correctly or not. Excellent point (I had completely missed this). Upated patch is attached. Currently regtesting. OK for trunk if this passes? Thomas 2010-08-28 Thomas Koenig PR fortran/45159 * dependency.c (gfc_deb_compare_expr): Compare equal for equal arglists for pure user functions, or for those intrinsic functions which are also pure. 2010-08-28 Thomas Koenig PR fortran/45159 * gfortran.dg/dependency_34.f90: New test. Index: dependency.c =================================================================== --- dependency.c (Revision 163584) +++ dependency.c (Arbeitskopie) @@ -353,39 +353,32 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) return -2; case EXPR_FUNCTION: - /* We can only compare calls to the same intrinsic function. */ - if (e1->value.function.isym == 0 || e2->value.function.isym == 0 - || e1->value.function.isym != e2->value.function.isym) - return -2; - args1 = e1->value.function.actual; - args2 = e2->value.function.actual; - - /* We should list the "constant" intrinsic functions. Those - without side-effects that provide equal results given equal - argument lists. */ - switch (e1->value.function.isym->id) + /* PURE functions can be compared for argument equality. */ + if ((e1->value.function.esym && e2->value.function.esym + && e1->value.function.esym == e2->value.function.esym + && e1->value.function.esym->result->attr.pure) + || (e1->value.function.isym && e2->value.function.isym + && e1->value.function.isym == e2->value.function.isym + && e1->value.function.isym->pure)) { + args1 = e1->value.function.actual; + args2 = e2->value.function.actual; - case GFC_ISYM_REAL: - case GFC_ISYM_LOGICAL: - case GFC_ISYM_DBLE: - break; - - default: - return -2; + /* Compare the argument lists for equality. */ + while (args1 && args2) + { + if (gfc_dep_compare_expr (args1->expr, args2->expr) != 0) + return -2; + args1 = args1->next; + args2 = args2->next; + } + return (args1 || args2) ? -2 : 0; } + else + return -2; + break; - /* Compare the argument lists for equality. */ - while (args1 && args2) - { - if (gfc_dep_compare_expr (args1->expr, args2->expr) != 0) - return -2; - args1 = args1->next; - args2 = args2->next; - } - return (args1 || args2) ? -2 : 0; - default: return -2; }