From patchwork Tue Apr 10 14:07:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 896735 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-476139-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="IG3J+5mo"; dkim-atps=neutral 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 40L8q200Pkz9s1p for ; Wed, 11 Apr 2018 00:35:40 +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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=SUNjpXr6d5oYROsoyogWfCyQHLE+G BgKMu+K68MVVCuTyocW3DJPytn1OfXA4rKnUUDzDPNcgUBRiQZWDtOGXBFVSTKt/ 2UluDXIKNQvrC3lDAq7mvtQHb1zOmxFiZOC8Uc2Q4r9rDKHIqaokqvhcCmhYQ9my kGAC84a8LO3s0Y= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=aqjg/456xKF8YmsYysCF4zMa+sk=; b=IG3 J+5moDTM2w/7+FZ+K98GO5wEbXHH6Bf5R18oVbiuhMSCDHBG5obMC3R50bSNT/Vu q91BZ43+DMdlTPaMgJcV30dMuUWA7PM6OmL/zWP5bMw+2XkAOxq826rj57SXpejb r2acxwr5xRWfamB+5LX5tByDtFre+KaXH6dTmCrc= Received: (qmail 59372 invoked by alias); 10 Apr 2018 14:35:32 -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 59347 invoked by uid 89); 10 Apr 2018 14:35:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=unavailable version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Apr 2018 14:35:30 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAFB54072474 for ; Tue, 10 Apr 2018 14:35:22 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68C65D7DF4 for ; Tue, 10 Apr 2018 14:35:19 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w3AE7E0k014198; Tue, 10 Apr 2018 16:07:14 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w3AE7Dc4014197; Tue, 10 Apr 2018 16:07:13 +0200 Date: Tue, 10 Apr 2018 16:07:13 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: fortran@gcc.gnu.org Subject: [PATCH] Fix fortran/openmp.c collapsed loop analysis (PR fortran/85313) Message-ID: <20180410140713.GI8577@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! Dunno what I was thinking when adding this if (j < i) break;, with it we never verify whether second and following loop iterators aren't used in third and following loops in collapse(3) and above loops. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2018-04-10 Jakub Jelinek PR fortran/85313 * openmp.c (resolve_omp_do): Remove bogus if (j < i) break;. (resolve_oacc_nested_loops): Likewise. Formatting fix. * gfortran.dg/gomp/pr85313.f90: New test. Jakub --- gcc/fortran/openmp.c.jj 2018-01-31 21:47:18.774155978 +0100 +++ gcc/fortran/openmp.c 2018-04-10 12:21:38.371945086 +0200 @@ -5600,8 +5600,6 @@ resolve_omp_do (gfc_code *code) "iteration space at %L", name, &do_code->loc); break; } - if (j < i) - break; do_code2 = do_code2->block->next; } } @@ -5765,12 +5763,10 @@ resolve_oacc_nested_loops (gfc_code *cod || gfc_find_sym_in_expr (ivar, do_code->ext.iterator->end) || gfc_find_sym_in_expr (ivar, do_code->ext.iterator->step)) { - gfc_error ("!$ACC LOOP %s loops don't form rectangular iteration space at %L", - clause, &do_code->loc); + gfc_error ("!$ACC LOOP %s loops don't form rectangular " + "iteration space at %L", clause, &do_code->loc); break; } - if (j < i) - break; do_code2 = do_code2->block->next; } } --- gcc/testsuite/gfortran.dg/gomp/pr85313.f90.jj 2018-04-10 12:14:54.438779463 +0200 +++ gcc/testsuite/gfortran.dg/gomp/pr85313.f90 2018-04-10 12:13:46.975751804 +0200 @@ -0,0 +1,25 @@ +! PR fortran/85313 +! { dg-do compile } + +!$omp do collapse(3) + do i = 1, 10 + do j = i, 20 ! { dg-error "form rectangular iteration space" } + do k = 1, 2 + end do + end do + end do +!$omp do collapse(3) + do i = 1, 10 + do j = 1, 5 + do k = i, 20 ! { dg-error "form rectangular iteration space" } + end do + end do + end do +!$omp do collapse(3) + do i = 1, 10 + do j = 1, 5 + do k = j, 20 ! { dg-error "form rectangular iteration space" } + end do + end do + end do +end