From patchwork Fri Jul 29 09:48:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp713211pxt; Fri, 29 Jul 2022 02:49:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vWmNa7S6FFvLOKaB+0XxujzAtRBQsmyODQfY9ZqVY8QA/BJdW/0zsuZtMajVqaXCsbUusZ X-Received: by 2002:a17:906:8462:b0:72b:4e05:a8c1 with SMTP id hx2-20020a170906846200b0072b4e05a8c1mr2230081ejc.443.1659088156229; Fri, 29 Jul 2022 02:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659088156; cv=none; d=google.com; s=arc-20160816; b=kkY/4yoS3jArQdP3wsTgSaqYqVHPUxri/ZUGUwGKMMlaas18jGZmjNDUROYhMDeBfy 1ddTbDtnpEnvxgk7IVE884+E76KdgwJuucDchh8kXBOUisxJ2WYh8z2O7RcuPPqP7SNR EYn/zrOWFh2jDmp5zp6MC8ME5Mg1lDDEBa9y6g2Z9b83fxGK0pybzzvSqxRIdqKvBWyo 9MDMHuhO9t+m0zs4LIoSqgRoUOirnLC/cTmTX1wR84rlYT4n/+dhmt6jFhWHJBea697s 0W+N9kKz18Q1dnm1FHJPupG2umnSvqt7WwgcWUfO5QwYx8Lj/qljJBdHxqW1XjLvdKov kvGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=J5AFv69ZQ0y7nuhwvtx9zH6iqH/ynhoszmetuug/ey0=; b=SwvbYUgl25l6EFTkuvr6nwjlx+wuSvEItb0tP8mtreTKzfNxleIoCoVSUe7XuATrGs aY25FlpM9k3elvOHx52RFYTT12Q3njSmiELa9PZDZJywgGErBmHnG9YqXXCWWDjfAtTl cEETnX7XwdM5BbxxqtiMSMImgFzQUwBldXpE4xLv9/CjFobmCtyqOP7WOliWX/3ZUdsx ydFGuyImeiKFTjp/3Cw3ka+i+rxLVL2xsnzKuurloACNGdjp/R5XMItrcIS9qtvitUfn oO432JjtpSbwXV0IZyTVHqeCW2x+EOgcxdD5vghPC3MP26ZzVaELVMn0QbzifYmj38xR +twA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id nb22-20020a1709071c9600b006fee7b0011csi3588507ejc.65.2022.07.29.02.49.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 02:49:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 128D23856DEE for ; Fri, 29 Jul 2022 09:48:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id D5587385782F for ; Fri, 29 Jul 2022 09:48:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5587385782F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,201,1654588800"; d="diff'?scan'208";a="80370862" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 29 Jul 2022 01:48:14 -0800 IronPort-SDR: VBZT6TMqqwqcVaaGe9LJ+J1RFzeY/3L1w9lmlBHVvoasQdOs9sAug51Ux8RIG7GNGBVcvO5Zwx lTKUzf+z+GFDvoNjKHEE+mW/UmUaQZunTQ8Lk/KeTUp6x5zGg2xd12LmWf2Ol0thYai14DfkUf cGxdhSIhBSMMJW7QsPijJBa5MABzLYkuDFL9c0U5ml6IkUGcIaQsOu97R2QopYdpIXaKpWoIsE 900bGlgEOk3Y/x+R0KqUhw5cI1yxCpvS/C1CkY34MCjz9mAiSCEPrOLCJEPHd7Rv9JFkk6PabH KBE= Message-ID: <21e39473-5bcc-02a0-fc64-564e0a606ac2@codesourcery.com> Date: Fri, 29 Jul 2022 11:48:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [Patch] Add libgomp.c-c++-common/pr106449-2.c (was: [committed] openmp: Fix up handling of non-rectangular simd loops with pointer type iterators [PR106449]) Content-Language: en-US To: Jakub Jelinek , References: From: Tobias Burnus In-Reply-To: X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739680022449220990?= X-GMAIL-MSGID: =?utf-8?q?1739680022449220990?= On 29.07.22 10:03, Jakub Jelinek wrote: > There were 2 issues visible on this new testcase, one that we didn't have > special POINTER_TYPE_P handling in a few spots of expand_omp_simd ... > The other issue was that we put n2 expression directly into a > comparison in a condition and regimplified that, for the &a[512] case that > and with gimplification being destructed that unfortunately meant modification > of original fd->loops[?].n2. Fixed by unsharing the expression. I created a testcase for the non-simd case – and due to messing up, it failed; hence, I filled PR middle-end/106467. After fixing the testcase, it passes. (→ closed PR as invalid). However, given that the testcase now exists, I think it makes sense to add it :-) Changes compared to the simd testcase: replaced '(parallel for) simd' by 'for', removed 'linear', used now 'b' and 'c' instead of storing both ptrs in 'b'. Side remark: Before GCC 12, GCC complained about "q = p + n" with "error: initializer expression refers to iteration variable ‘p’". OK for mainline? Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 Add libgomp.c-c++-common/pr106449-2.c This run-time test test pointer-based iteration with collapse, similar to the '(parallel) simd' test for PR106449 but for 'for'. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/pr106449-2.c: New test. .../testsuite/libgomp.c-c++-common/pr106449-2.c | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c b/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c new file mode 100644 index 00000000000..7fef7461bcf --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c @@ -0,0 +1,64 @@ +/* { dg-do run } */ + +/* Based on pr106449.c - but using 'for' instead of 'simd'. + Cf. PR middle-end/106449 (for pr106449.c) and PR middle-end/106467. */ + +void +foo (void) +{ + int a[1024], *b[65536], *c[65536]; + int *p, *q, **r = &b[0], **r2 = &c[0], i; + #pragma omp for collapse(2) + for (p = &a[0]; p < &a[512]; p++) + for (q = p + 64; q < p + 128; q++) + { + *r++ = p; + *r2++ = q; + } + for (i = 0; i < 32768; i++) + if (b[i] != &a[i / 64] || c[i] != &a[(i / 64) + 64 + (i % 64)]) + __builtin_abort (); +} + +void +bar (int n, int m) +{ + int a[1024], *b[32768], *c[32768]; + int *p, *q, **r = &b[0], **r2 = &c[0], i; + #pragma omp for collapse(2) + for (p = &a[0]; p < &a[512]; p++) + for (q = p + n; q < p + m; q++) + { + *r++ = p; + *r2++ = q; + } + for (i = 0; i < 32768; i++) + if (b[i] != &a[i / 64] || c[i] != &a[(i / 64) + 64 + (i % 64)]) + __builtin_abort (); +} + +void +baz (int n, int m) +{ + int a[1024], *b[8192], *c[8192]; + int *p, *q, **r = &b[0], **r2 = &c[0], i; + #pragma omp for collapse(2) + for (p = &a[0]; p < &a[512]; p += 4) + for (q = p + n; q < p + m; q += 2) + { + *r++ = p; + *r2++ = q; + } + for (i = 0; i < 4096; i++) + if (b[i] != &a[(i / 32) * 4] || c[i] != &a[(i / 32) * 4 + 64 + (i % 32) * 2]) + __builtin_abort (); +} + +int +main () +{ + foo (); + bar (64, 128); + baz (64, 128); + return 0; +}