From patchwork Wed Jun 12 19:00:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1114783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502858-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45PGRx0Xzxz9sBb for ; Thu, 13 Jun 2019 05:01:07 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=VkwTNA5Tb3Wf52P7gZXvbeAzZCnWSKA0OyxUAHCyWTb 3JAW0t3djqA0KkQwxgTNrwgAnCWGRS7Lc9UENC398rbuW4Uy0QxQ0quI2twTp/BD 1zUNHiRqrp6AHMQ4B5tS3+ASJzSpwafez3PrV868go5QCJahfcZQGPp2KLgNYUl8 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=qsLkvs36oZ7cy9z/0S4clg0RMNc=; b=IF4DdNrSJm3HB3k6T jq/1qaT+7TV2n1oNJFa8KCegK1LWt9bzhxq2jrhzZIzBkhtUNRa4kdeAd/hRpPpI dWmeUzo+egIIDDw8GeZL4BQ994c2chAqhVn+j4bTT78zMjcwRRffthydCtJW4MM5 vRefDK/Y3pSghMdsJz76gKghfY= Received: (qmail 107243 invoked by alias); 12 Jun 2019 19:00:55 -0000 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 Received: (qmail 107117 invoked by uid 89); 12 Jun 2019 19:00:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=formatting X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Jun 2019 19:00:42 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x5CJ0eQK048208 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 12 Jun 2019 12:00:40 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x5CJ0bEB048207; Wed, 12 Jun 2019 12:00:37 -0700 (PDT) (envelope-from sgk) Date: Wed, 12 Jun 2019 12:00:37 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/88810 -- Code clean up Message-ID: <20190612190037.GA48174@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.4 (2019-03-13) This PR flags a section of confusing but correct code. The attach patch rewrites the code to hopefully provide some clarity. It has lived my tree for around 6 months, so has sufferred through numerous regression tests. OK to commit? 2019-06-12 Steven G. Kargl PR fortran/88810 * dependency.c (gfc_dep_resolver): Re-arrange code to make the logic a bit more transparent. Fix 2 nearby formatting issues. Index: gcc/fortran/dependency.c =================================================================== --- gcc/fortran/dependency.c (revision 268276) +++ gcc/fortran/dependency.c (working copy) @@ -2141,7 +2141,7 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_re /* Index for the reverse array. */ m = -1; - for (n=0; n < lref->u.ar.dimen; n++) + for (n = 0; n < lref->u.ar.dimen; n++) { /* Handle dependency when either of array reference is vector subscript. There is no dependency if the vector indices @@ -2163,7 +2163,8 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_re if (lref->u.ar.dimen_type[n] == DIMEN_RANGE && rref->u.ar.dimen_type[n] == DIMEN_RANGE) - this_dep = check_section_vs_section (&lref->u.ar, &rref->u.ar, n); + this_dep = check_section_vs_section (&lref->u.ar, + &rref->u.ar, n); else if (lref->u.ar.dimen_type[n] == DIMEN_ELEMENT && rref->u.ar.dimen_type[n] == DIMEN_RANGE) this_dep = gfc_check_element_vs_section (lref, rref, n); @@ -2196,35 +2197,38 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_re if (rref->u.ar.dimen_type[n] == DIMEN_RANGE && lref->u.ar.dimen_type[n] == DIMEN_RANGE) { - /* Set reverse if backward dependence and not inhibited. */ - if (reverse && reverse[m] == GFC_ENABLE_REVERSE) - reverse[m] = (this_dep == GFC_DEP_BACKWARD) ? - GFC_REVERSE_SET : reverse[m]; + if (reverse) + { + /* Reverse if backward dependence and not inhibited. */ + if (reverse[m] == GFC_ENABLE_REVERSE + && this_dep == GFC_DEP_BACKWARD) + reverse[m] = GFC_REVERSE_SET; - /* Set forward if forward dependence and not inhibited. */ - if (reverse && reverse[m] == GFC_ENABLE_REVERSE) - reverse[m] = (this_dep == GFC_DEP_FORWARD) ? - GFC_FORWARD_SET : reverse[m]; + /* Forward if forward dependence and not inhibited. */ + if (reverse[m] == GFC_ENABLE_REVERSE + && this_dep == GFC_DEP_FORWARD) + reverse[m] = GFC_FORWARD_SET; - /* Flag up overlap if dependence not compatible with - the overall state of the expression. */ - if (reverse && reverse[m] == GFC_REVERSE_SET - && this_dep == GFC_DEP_FORWARD) - { - reverse[m] = GFC_INHIBIT_REVERSE; - this_dep = GFC_DEP_OVERLAP; + /* Flag up overlap if dependence not compatible with + the overall state of the expression. */ + if (reverse[m] == GFC_REVERSE_SET + && this_dep == GFC_DEP_FORWARD) + { + reverse[m] = GFC_INHIBIT_REVERSE; + this_dep = GFC_DEP_OVERLAP; + } + else if (reverse[m] == GFC_FORWARD_SET + && this_dep == GFC_DEP_BACKWARD) + { + reverse[m] = GFC_INHIBIT_REVERSE; + this_dep = GFC_DEP_OVERLAP; + } } - else if (reverse && reverse[m] == GFC_FORWARD_SET - && this_dep == GFC_DEP_BACKWARD) - { - reverse[m] = GFC_INHIBIT_REVERSE; - this_dep = GFC_DEP_OVERLAP; - } /* If no intention of reversing or reversing is explicitly inhibited, convert backward dependence to overlap. */ - if ((reverse == NULL && this_dep == GFC_DEP_BACKWARD) - || (reverse != NULL && reverse[m] == GFC_INHIBIT_REVERSE)) + if ((!reverse && this_dep == GFC_DEP_BACKWARD) + || (reverse && reverse[m] == GFC_INHIBIT_REVERSE)) this_dep = GFC_DEP_OVERLAP; }