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: 378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp204172pxt; Thu, 4 Aug 2022 00:33:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Z3hw3KboAk+waCXRmUv6rHfu1bWtcg+A0BRYpbdl6jZ9fOiI8/ehgfcWoJxDhryXnW/0Y X-Received: by 2002:a17:907:6daa:b0:730:8ef6:9c6b with SMTP id sb42-20020a1709076daa00b007308ef69c6bmr474470ejc.6.1659598388673; Thu, 04 Aug 2022 00:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659598388; cv=none; d=google.com; s=arc-20160816; b=JQfgsvZikTl3cDGE/ZZJ+o5/PEiDd5YiwrJmx7in2L2Atli7Px6BRbwkPmwiLHR0FI 8CiyK6ptbGpCirQEGq9D5Hbs35YNbI9p2IDkNU5J9IhGoNJd1x4tWONWSzfMWdi2IVQH vKvyYiWoTD35xst+pdqQvXmQAVW0BWDCxe5RB7c4+Cs6dY9c1cgcMLOSR3U2ZthXJlPA BuS/3BreJP6hourn/jg//Dof2QpZoVqWp1ZHm35279+4aGi0dOHwhxc2jk/Vt197D5rQ z0ZWl6nCeTkQiT+MJdhQDMFnJZaq2DVu25MsNa/mKzWOpgLqnYqVgLvIhyy+CySrPCrf 4B+g== 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:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=kNRoLgeOf1itw5ABj9WwsqhjDthlZFVJgEBzghGbSjI=; b=GaM88WB1VQjU9cfcaRKlz1wCPg88pBWtAebBTvfS3QSTlmFY/DAlBuAsSNphbvf7ux 2kJ8La4Lk6RfowzJVl5GAC+zg+pNzGbIgrliX4MKb+duiAQtjibfYKmQaQ6d9t2Pfcei nVqmpJOrxSe6YZVS/VhbhuDjW0vG7/JH2+eYeFAi9go/4ZaLYhza52IfTXRCeMiz+jWS RFnhbh7fyl2YsOSHS1IyHxIZoN2dnW/rjwi7z9NSlDXUX4s1xW/Lu768eQjqdd0XmpQ9 /xxlZGDTXPJr3p6brV2+JVapW0DEjk9l/8Sj7ilxwiR79qveV4LyAf0bW4tqjqbI3h+d 77Ug== 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 sa2-20020a1709076d0200b006ff49b183e9si1200ejc.971.2022.08.04.00.33.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 00:33:08 -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 8B264385AE75 for ; Thu, 4 Aug 2022 07:33:03 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740215039786973559?= X-GMAIL-MSGID: =?utf-8?q?1740215039786973559?= 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]);