From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3BC4A3858D1E for ; Wed, 17 Aug 2022 12:38:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3BC4A3858D1E Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-231-okmFeHEcM7uzTbxJ6HceJg-1; Wed, 17 Aug 2022 08:38:44 -0400 X-MC-Unique: okmFeHEcM7uzTbxJ6HceJg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7AE85294EDC2; Wed, 17 Aug 2022 12:38:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3379EC15BB3; Wed, 17 Aug 2022 12:38:43 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 27HCcfn83133456 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Aug 2022 14:38:41 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 27HCcerq3133455; Wed, 17 Aug 2022 14:38:40 +0200 Date: Wed, 17 Aug 2022 14:38:40 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches Subject: Re: [Patch] OpenMP: Fix var replacement with 'simd' and linear-step vars [PR106548] Message-ID: Reply-To: Jakub Jelinek References: <52902f75-33c1-49c3-8e21-e6c6d1808a15@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <52902f75-33c1-49c3-8e21-e6c6d1808a15@codesourcery.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: , X-List-Received-Date: Wed, 17 Aug 2022 12:38:49 -0000 On Tue, Aug 16, 2022 at 05:28:40PM +0200, Tobias Burnus wrote: > The testcase is just a copy of linear-1 with 'omp ... for' replaced by 'omp ... for simd', > matching what the PR report referred to. > > The problem occurs for 'omp ... for simd linear( i : step)' when 'step' is a variable > when a omp_fn... is generated - as in this case, the original variable is used (in the > reduced example of the PR, the PARM_DECL of 'f') instead of the replacement. > > OK for mainline? Thoughts on backporting (and for which versions)? > > 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 var replacement with 'simd' and linear-step vars [PR106548] > > gcc/ChangeLog: > > PR middle-end/106548 > * omp-low.cc (lower_rec_input_clauses): Use build_outer_var_ref > for 'simd' linear-step values that are variable. > > libgomp/ChangeLog: > > PR middle-end/106548 > * testsuite/libgomp.c/linear-2.c: New test. > > diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc > index 3c4b8593c8b..d6d6ff372a1 100644 > --- a/gcc/omp-low.cc > +++ b/gcc/omp-low.cc > @@ -6188,6 +6188,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, > && gimple_omp_for_combined_into_p (ctx->stmt)) > { > tree t = OMP_CLAUSE_LINEAR_STEP (c); > + if (VAR_P (t) > + || TREE_CODE (t) == PARM_DECL > + || TREE_CODE (t) == RESULT_DECL) > + t = build_outer_var_ref (t, ctx); I think this should be just if (DECL_P (t)) t = build_outer_var_ref (t, ctx); Ok with that change. With backports I'd wait a week or two (12.2 is frozen anyway), can be applied to any open release branches you are willing to backport it to. > --- /dev/null > +++ b/libgomp/testsuite/libgomp.c/linear-2.c > @@ -0,0 +1,251 @@ > +/* PR middle-end/106548. */ Usually simd related runtime tests in libgomp use something like /* { dg-do run } */ /* { dg-additional-options "-msse2" { target sse2_runtime } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ to test some actual vectorization if possible. Jakub