From patchwork Wed Feb 7 11:05:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 870303 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-472745-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CLdISvpv"; 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 3zbz5h2l0rz9s1h for ; Wed, 7 Feb 2018 22:05:59 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=EqgIY+9xPxEQdOSsgOZaZBFd+KAo1Vend9tRnMTRgJn4wBBaDF suUGBP/wlbbbnPLxCfzlNPul9JHXXQtWQNUmVH0xkJ/aaI7LEr+ovRulcE2IBSkw jiVkeTwJ0SkHx1T2PV5bYE9T6vaz5/blf0PvptRajtENCD15fwk3+yc3w= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=jvvQJfzu8iWaqEPPIbKm6Foxtw4=; b=CLdISvpvliwAuRoz06pF 716ICfEY7uXe1Di4dW5HWWt8th5XXOF80hNvdIEdUf3z3bzI3f98WyXvgQJqFL9H cYdZzjw7McK4PobCCLcO6biYxG0EOjVJMVQ5FfBKySHYyY3uDOuXD52SOzsu1DRV wNLIk/U6pZjULgp7BqFpLok= Received: (qmail 107511 invoked by alias); 7 Feb 2018 11:05:52 -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 107500 invoked by uid 89); 7 Feb 2018 11:05:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 11:05:49 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1ejNXu-0006Jz-Ft from Tom_deVries@mentor.com ; Wed, 07 Feb 2018 03:05:46 -0800 Received: from [172.30.64.70] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 7 Feb 2018 11:05:42 +0000 To: Jakub Jelinek , Thomas Schwinge CC: GCC Patches , Richard Biener From: Tom de Vries Subject: [openacc, committed] Fix diff_type in expand_oacc_collapse_init Message-ID: Date: Wed, 7 Feb 2018 12:05:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Hi, this patch fixes an 8 regression in an openacc testcase. The regression was introduced by r250925, a fix for PR78266, a bug in the handling of a loop with iteration variable type range smaller than the size of the parallel dimension the loop is assigned to. The fix for the regression is to apply the r250925 fix (in expand_oacc_for) to expand_oacc_collapse_init as well. Build and reg-tested on x86_64 with nvptx accelerator. Committed to stage4 trunk. Thanks, - Tom [openacc] Fix diff_type in expand_oacc_collapse_init 2018-02-07 Tom de Vries PR libgomp/84217 * omp-expand.c (expand_oacc_collapse_init): Ensure diff_type is large enough. * c-c++-common/goacc/pr84217.c: New test. * gfortran.dg/goacc/pr84217.f90: New test. * testsuite/libgomp.oacc-c-c++-common/pr84217.c: New test. --- gcc/omp-expand.c | 2 ++ gcc/testsuite/c-c++-common/goacc/pr84217.c | 8 ++++++++ gcc/testsuite/gfortran.dg/goacc/pr84217.f90 | 9 +++++++++ .../testsuite/libgomp.oacc-c-c++-common/pr84217.c | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index 90e0631..bb20490 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -1433,6 +1433,8 @@ expand_oacc_collapse_init (const struct omp_for_data *fd, plus_type = sizetype; if (POINTER_TYPE_P (diff_type) || TYPE_UNSIGNED (diff_type)) diff_type = signed_type_for (diff_type); + if (TYPE_PRECISION (diff_type) < TYPE_PRECISION (integer_type_node)) + diff_type = integer_type_node; if (tiling) { diff --git a/gcc/testsuite/c-c++-common/goacc/pr84217.c b/gcc/testsuite/c-c++-common/goacc/pr84217.c new file mode 100644 index 0000000..c4f2920 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/pr84217.c @@ -0,0 +1,8 @@ +void +foo (void) +{ +#pragma acc parallel loop tile (2, 3) + for (short i = 0; i < 10; ++i) + for (short j = 0; j < 10; ++j) + ; +} diff --git a/gcc/testsuite/gfortran.dg/goacc/pr84217.f90 b/gcc/testsuite/gfortran.dg/goacc/pr84217.f90 new file mode 100644 index 0000000..cee49e9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr84217.f90 @@ -0,0 +1,9 @@ +subroutine foo + integer(2) :: i, j + !$acc parallel loop tile(2,3) + do i = 1, 10 + do j = 1, 10 + end do + end do + !$acc end parallel loop +end diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c new file mode 100644 index 0000000..18ff66a --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c @@ -0,0 +1,22 @@ +extern void abort (void); + +#define N 10 + +int +main (void) +{ + int a[N]; + + for (short i = 0; i < N; ++i) + a[i] = -1; + +#pragma acc parallel loop tile (2) + for (short i = 0; i < N; ++i) + a[i] = i; + + for (short i = 0; i < N; ++i) + if (a[i] != i) + abort (); + + return 0; +}