From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128243 invoked by alias); 13 Jul 2015 11:03:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 128230 invoked by uid 89); 13 Jul 2015 11:03:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 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; Mon, 13 Jul 2015 11:03:01 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52351) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZEbVj-0008Dp-DJ for gcc-patches@gnu.org; Mon, 13 Jul 2015 07:02:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEbVe-0005ZV-UH for gcc-patches@gnu.org; Mon, 13 Jul 2015 07:02:58 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:36059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEbVe-0005ZL-PS for gcc-patches@gnu.org; Mon, 13 Jul 2015 07:02:54 -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 1ZEbVd-0004E3-TW from Tom_deVries@mentor.com for gcc-patches@gnu.org; Mon, 13 Jul 2015 04:02:54 -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; Mon, 13 Jul 2015 12:02:51 +0100 Message-ID: <55A39AD5.1020006@mentor.com> Date: Mon, 13 Jul 2015 11:03:00 -0000 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: [PATCH, PR46193] Handle mix/max pointer reductions in parloops Content-Type: multipart/mixed; boundary="------------080409060708010200070708" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2015-07/txt/msg01018.txt.bz2 --------------080409060708010200070708 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 165 Hi, this patch fixes PR46193. It handles min and max reductions of pointer type in parloops. Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom --------------080409060708010200070708 Content-Type: text/x-patch; name="0001-Handle-mix-max-pointer-reductions-in-parloops.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-Handle-mix-max-pointer-reductions-in-parloops.patch" Content-length: 3383 Handle mix/max pointer reductions in parloops 2015-07-13 Tom de Vries PR tree-optimization/46193 * omp-low.c (omp_reduction_init): Handle pointer type for min or max clause. * gcc.dg/autopar/pr46193.c: New test. * testsuite/libgomp.c/pr46193.c: New test. --- gcc/omp-low.c | 4 ++ gcc/testsuite/gcc.dg/autopar/pr46193.c | 38 +++++++++++++++++++ libgomp/testsuite/libgomp.c/pr46193.c | 67 ++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/autopar/pr46193.c create mode 100644 libgomp/testsuite/libgomp.c/pr46193.c diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 2e2070a..20d0010 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -3423,6 +3423,8 @@ omp_reduction_init (tree clause, tree type) real_maxval (&min, 1, TYPE_MODE (type)); return build_real (type, min); } + else if (POINTER_TYPE_P (type)) + return lower_bound_in_type (type, type); else { gcc_assert (INTEGRAL_TYPE_P (type)); @@ -3439,6 +3441,8 @@ omp_reduction_init (tree clause, tree type) real_maxval (&max, 0, TYPE_MODE (type)); return build_real (type, max); } + else if (POINTER_TYPE_P (type)) + return upper_bound_in_type (type, type); else { gcc_assert (INTEGRAL_TYPE_P (type)); diff --git a/gcc/testsuite/gcc.dg/autopar/pr46193.c b/gcc/testsuite/gcc.dg/autopar/pr46193.c new file mode 100644 index 0000000..544a5da --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr46193.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops-details" } */ + +extern void abort (void); + +char * +foo (int count, char **list) +{ + char *minaddr = list[0]; + int i; + + for (i = 0; i < count; i++) + { + char *addr = list[i]; + if (addr < minaddr) + minaddr = addr; + } + + return minaddr; +} + +char * +foo2 (int count, char **list) +{ + char *maxaddr = list[0]; + int i; + + for (i = 0; i < count; i++) + { + char *addr = list[i]; + if (addr > maxaddr) + maxaddr = addr; + } + + return maxaddr; +} + +/* { dg-final { scan-tree-dump-times "parallelizing inner loop" 2 "parloops" } } */ diff --git a/libgomp/testsuite/libgomp.c/pr46193.c b/libgomp/testsuite/libgomp.c/pr46193.c new file mode 100644 index 0000000..1e27faf --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr46193.c @@ -0,0 +1,67 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=2" } */ + +extern void abort (void); + +char * +foo (int count, char **list) +{ + char *minaddr = list[0]; + int i; + + for (i = 0; i < count; i++) + { + char *addr = list[i]; + if (addr < minaddr) + minaddr = addr; + } + + return minaddr; +} + +char * +foo2 (int count, char **list) +{ + char *maxaddr = list[0]; + int i; + + for (i = 0; i < count; i++) + { + char *addr = list[i]; + if (addr > maxaddr) + maxaddr = addr; + } + + return maxaddr; +} + +#define N 5 + +static void +init (char **list) +{ + int i; + for (i = 0; i < N; ++i) + list[i] = (char *)&list[i]; +} + +int +main (void) +{ + char *list[N]; + char * res; + + init (list); + + res = foo (N, list); + + if (res != (char *)&list[0]) + abort (); + + res = foo2 (N, list); + + if (res != (char *)&list[N-1]) + abort (); + + return 0; +} -- 1.9.1 --------------080409060708010200070708--