From patchwork Tue Jun 30 11:03:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 489648 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7894D1402C0 for ; Tue, 30 Jun 2015 21:04:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fo7V+3MC; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=Iw0Yr779MQtfwHwYZJwZQbHHcpfrZ/k4rub7PN0/9xRKSE aGrFVJzACqneKISIf99WTsA+8gzYVWnSHqkAYsolNvpnqKUbc1LXGTyVwU/m+p30 HhhIC1+OMg6DKZRIyxPEJj1/8B8N8Jc9dole9m0mDClWGRD2m3gyDjq/0uUDw= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=1meBSZlEk1x9LUTcleOz5vlvtiA=; b=fo7V+3MCg/cfhLBXkxWj dCvN6o0q6YbJoRPOUvuIZhFfIm+c86ZKhNRseDNiHqD/PLazJrZr+e9Ldr+TvKmO mp+3AMqeiof0olPy5Q5Bms2tGJQmd/OYIADOzItzCbm8z9jE/JS5MzmYNFmj0WUG umYKEo9ezNPHS1nkOkZvYZ4= Received: (qmail 101021 invoked by alias); 30 Jun 2015 11:03:47 -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 101008 invoked by uid 89); 30 Jun 2015 11:03:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 30 Jun 2015 11:03:43 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48043) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Z9tKH-00009S-8G for gcc-patches@gnu.org; Tue, 30 Jun 2015 07:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9tKB-0002VZ-4y for gcc-patches@gnu.org; Tue, 30 Jun 2015 07:03:40 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:34381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9tKA-0002VM-Sv for gcc-patches@gnu.org; Tue, 30 Jun 2015 07:03:35 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Z9tK8-0004am-S6 from Tom_deVries@mentor.com for gcc-patches@gnu.org; Tue, 30 Jun 2015 04:03:33 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Tue, 30 Jun 2015 12:03:30 +0100 Message-ID: <5592777B.40704@mentor.com> Date: Tue, 30 Jun 2015 13:03:23 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "gcc-patches@gnu.org" Subject: [committed] Add parloops-exit-first-loop-alt-{5,6,7}.c X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Hi, This patch adds variants of parloops-exit-first-loop-alt.c, to cover all combinations of loop bound signed/unsigned and loop counter signed/unsigned. Committed to trunk. Thanks, - Tom Add parloops-exit-first-loop-alt-{5,6,7}.c 2015-06-29 Tom de Vries * gcc.dg/parloops-exit-first-loop-alt-5.c: New test. * gcc.dg/parloops-exit-first-loop-alt-6.c: New test. * gcc.dg/parloops-exit-first-loop-alt-7.c: New test. * gcc.dg/parloops-exit-first-loop-alt.c: Update comment. * testsuite/libgomp.c/parloops-exit-first-loop-alt-5.c: New test. * testsuite/libgomp.c/parloops-exit-first-loop-alt-6.c: New test. * testsuite/libgomp.c/parloops-exit-first-loop-alt-7.c: New test. * testsuite/libgomp.c/parloops-exit-first-loop-alt.c: Update comment. --- .../gcc.dg/parloops-exit-first-loop-alt-5.c | 22 +++++++ .../gcc.dg/parloops-exit-first-loop-alt-6.c | 22 +++++++ .../gcc.dg/parloops-exit-first-loop-alt-7.c | 22 +++++++ .../gcc.dg/parloops-exit-first-loop-alt.c | 2 +- .../libgomp.c/parloops-exit-first-loop-alt-5.c | 75 ++++++++++++++++++++++ .../libgomp.c/parloops-exit-first-loop-alt-6.c | 75 ++++++++++++++++++++++ .../libgomp.c/parloops-exit-first-loop-alt-7.c | 75 ++++++++++++++++++++++ .../libgomp.c/parloops-exit-first-loop-alt.c | 2 +- 8 files changed, 293 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-5.c create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-6.c create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-7.c create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-5.c create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-6.c create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-7.c diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-5.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-5.c new file mode 100644 index 0000000..3f799cf --- /dev/null +++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-5.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */ + +/* Variable bound, vector addition, unsigned loop counter, unsigned bound. */ + +void +f (unsigned int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, + unsigned int *__restrict__ c) +{ + unsigned int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +/* Three times a store: + - one in f._loopfn.0 + - one in the parallel + - one in the low iteration count loop + Crucially, none for a peeled off last iteration following the parallel. */ +/* { dg-final { scan-tree-dump-times "(?n)^ \\*_\[0-9\]*" 3 "parloops" } } */ diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-6.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-6.c new file mode 100644 index 0000000..ee19a55 --- /dev/null +++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-6.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */ + +/* Variable bound, vector addition, unsigned loop counter, signed bound. */ + +void +f (int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, + unsigned int *__restrict__ c) +{ + unsigned int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +/* Three times a store: + - one in f._loopfn.0 + - one in the parallel + - one in the low iteration count loop + Crucially, none for a peeled off last iteration following the parallel. */ +/* { dg-final { scan-tree-dump-times "(?n)^ \\*_\[0-9\]*" 3 "parloops" } } */ diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-7.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-7.c new file mode 100644 index 0000000..c337342 --- /dev/null +++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-7.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */ + +/* Variable bound, vector addition, signed loop counter, signed bound. */ + +void +f (int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, + unsigned int *__restrict__ c) +{ + int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +/* Three times a store: + - one in f._loopfn.0 + - one in the parallel + - one in the low iteration count loop + Crucially, none for a peeled off last iteration following the parallel. */ +/* { dg-final { scan-tree-dump-times "(?n)^ \\*_\[0-9\]*" 3 "parloops" } } */ diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c index e088fa1..0b69165 100644 --- a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c +++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c @@ -2,7 +2,7 @@ /* { dg-require-effective-target pthread } */ /* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */ -/* Variable bound, vector addition. */ +/* Variable bound, vector addition, signed loop counter, unsigned bound. */ void f (unsigned int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-5.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-5.c new file mode 100644 index 0000000..d8d49b4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-5.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=2" } */ + +/* Variable bound, vector addition, unsigned loop counter, unsigned bound. */ + +#include +#include + +#define N 1000 + +unsigned int a[N]; +unsigned int b[N]; +unsigned int c[N]; + +void __attribute__((noclone,noinline)) +f (unsigned int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, + unsigned int *__restrict__ c) +{ + unsigned int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +static void __attribute__((noclone,noinline)) +init (void) +{ + int i, j; + + /* Complexify loop to inhibit parloops. */ + for (j = 0; j < 100; ++j) + for (i = 0; i < 10; i++) + { + int k = i + (10 * j); + a[k] = k; + b[k] = (k * 3) % 7; + c[k] = k * 2; + } +} + +int +main (void) +{ + int i; + + init (); + + f (N, a, b, c); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = i + ((i * 3) % 7); + if (actual != expected) + abort (); + } + + /* Test low iteration count case. */ + + init (); + + f (10, a, b, c); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = (i < 10 + ? i + ((i * 3) % 7) + : i * 2); + if (actual != expected) + abort (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-6.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-6.c new file mode 100644 index 0000000..99c61c0 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-6.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=2" } */ + +/* Variable bound, vector addition, unsigned loop counter, signed bound. */ + +#include +#include + +#define N 1000 + +unsigned int a[N]; +unsigned int b[N]; +unsigned int c[N]; + +void __attribute__((noclone,noinline)) +f (int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, + unsigned int *__restrict__ c) +{ + unsigned int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +static void __attribute__((noclone,noinline)) +init (void) +{ + int i, j; + + /* Complexify loop to inhibit parloops. */ + for (j = 0; j < 100; ++j) + for (i = 0; i < 10; i++) + { + int k = i + (10 * j); + a[k] = k; + b[k] = (k * 3) % 7; + c[k] = k * 2; + } +} + +int +main (void) +{ + int i; + + init (); + + f (N, a, b, c); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = i + ((i * 3) % 7); + if (actual != expected) + abort (); + } + + /* Test low iteration count case. */ + + init (); + + f (10, a, b, c); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = (i < 10 + ? i + ((i * 3) % 7) + : i * 2); + if (actual != expected) + abort (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-7.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-7.c new file mode 100644 index 0000000..1f6e5e4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-7.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=2" } */ + +/* Variable bound, vector addition, signed loop counter, signed bound. */ + +#include +#include + +#define N 1000 + +unsigned int a[N]; +unsigned int b[N]; +unsigned int c[N]; + +void __attribute__((noclone,noinline)) +f (int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b, + unsigned int *__restrict__ c) +{ + int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +static void __attribute__((noclone,noinline)) +init (void) +{ + int i, j; + + /* Complexify loop to inhibit parloops. */ + for (j = 0; j < 100; ++j) + for (i = 0; i < 10; i++) + { + int k = i + (10 * j); + a[k] = k; + b[k] = (k * 3) % 7; + c[k] = k * 2; + } +} + +int +main (void) +{ + int i; + + init (); + + f (N, a, b, c); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = i + ((i * 3) % 7); + if (actual != expected) + abort (); + } + + /* Test low iteration count case. */ + + init (); + + f (10, a, b, c); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = (i < 10 + ? i + ((i * 3) % 7) + : i * 2); + if (actual != expected) + abort (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c index 07468a9..d67a4f6 100644 --- a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-additional-options "-ftree-parallelize-loops=2" } */ -/* Variable bound, vector addition. */ +/* Variable bound, vector addition, signed loop counter, unsigned bound. */ #include #include -- 1.9.1