From patchwork Thu Aug 4 07:32:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1663587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lz0nM0SvCz9sGV for ; Thu, 4 Aug 2022 17:32:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 682DD385AE5D for ; Thu, 4 Aug 2022 07:32:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 0231C3858C00 for ; Thu, 4 Aug 2022 07:32:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0231C3858C00 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,215,1654588800"; d="diff'?scan'208";a="80768746" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 03 Aug 2022 23:32:29 -0800 IronPort-SDR: lMyY6XRPbKAQu4vgp1H21VjIwuRsv+xMbcSO6cbVZBYGPgZWf5Nzt/5T0vR8a4tAl07tMEk/DK +cRnNDRXABT2+0bHY9ByyI2chVg/rOuKP3Ley7cUQIosgoZFVeUojixeoO/Ld605V74Fwr6yFT QuQXwNSktzBmFYESz1m2j49oNgSK/lOPKm7ZKZlMBXihoAFAQxf+3L2GCWWrWU7EzO6ouwUuzd oSSp6pr/Z03sRi3KZgjIaFqV9rDoq7b0Oi12JEBHccHXJqN0LC+68I6jY4aCuysdbLnrKphy8N fSY= Message-ID: Date: Thu, 4 Aug 2022 09:32:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: [Patch] OpenMP: Fix folding with simd's linear clause [PR106492] X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Rather obvious fix and similar to PR106449. OK for mainline and backporting (how far?). I would like to backport it at least to GCC 12. 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 OpenMP: Fix folding with simd's linear clause [PR106492] gcc/ChangeLog: PR middle-end/106492 * omp-low.cc (lower_rec_input_clauses): Add missing folding to data type of linear-clause list item. gcc/testsuite/ChangeLog: PR middle-end/106492 * g++.dg/gomp/pr106492.C: New test. gcc/omp-low.cc | 6 ++--- gcc/testsuite/g++.dg/gomp/pr106492.C | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc index d73c165f029..3c4b8593c8b 100644 --- a/gcc/omp-low.cc +++ b/gcc/omp-low.cc @@ -6241,10 +6241,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } if (POINTER_TYPE_P (TREE_TYPE (x))) - x = fold_build2 (POINTER_PLUS_EXPR, - TREE_TYPE (x), x, t); + x = fold_build_pointer_plus (x, t); else - x = fold_build2 (PLUS_EXPR, TREE_TYPE (x), x, t); + x = fold_build2 (PLUS_EXPR, TREE_TYPE (x), x, + fold_convert (TREE_TYPE (x), t)); } if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR diff --git a/gcc/testsuite/g++.dg/gomp/pr106492.C b/gcc/testsuite/g++.dg/gomp/pr106492.C new file mode 100644 index 00000000000..f263bb42710 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr106492.C @@ -0,0 +1,49 @@ +/* PR middle-end/106492 */ + +template +struct S { + T a : 12; + S () : a(0) + { +#pragma omp for simd linear(a) + for (int k = 0; k < 64; ++k) + a++; + } +}; +struct U { + int a : 12; + U () : a(0) + { +#pragma omp for simd linear(a) + for (int k = 0; k < 64; ++k) + a++; + } +}; + +S s; +U u; + + +template +struct Sptr { + T a; + Sptr (T init) : a(init) + { +#pragma omp for simd linear(a) + for (int k = 0; k < 64; ++k) + a++; + } +}; +struct Uptr { + int *a; + Uptr (int *init) : a(init) + { +#pragma omp for simd linear(a) + for (int k = 0; k < 64; ++k) + a++; + } +}; + +int i[1024]; +Sptr sptr(i); +Uptr uptr(&i[100]);