From patchwork Thu Feb 2 09:00:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 51806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp123439wrn; Thu, 2 Feb 2023 01:01:57 -0800 (PST) X-Google-Smtp-Source: AK7set87NMnSkt8wJUEJM+qxYuC33r70zHCR5YcLQSw/0DDUgjGf+DoBqHBXhFJXUNPLBbCREu+P X-Received: by 2002:a17:907:362:b0:868:b2b6:ee71 with SMTP id rs2-20020a170907036200b00868b2b6ee71mr5446736ejb.6.1675328517145; Thu, 02 Feb 2023 01:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675328517; cv=none; d=google.com; s=arc-20160816; b=kw2C32OXk1+2FZbgsaldGNnYZ+/WbBokjsnDq54rCERDyPs3BEOPCxjs6Or34y6kRv EIeDI0beSrwOcX8H4zv0sHg65ilbV3JReFeqNwIwfilgb+qMSknF8wL6TbE1VX9pp1GM ykNyHh7oQRfoRB+Xh4WC9X3mqfg3P7wqkSi67iPPLXA8DJpLDoeY/bFOPzDVjCcjx9UJ 8dsZEVTNbdZIkch0iRdfRHcGgEs9rj/lbhb7P16b28jn82LRNGDwkIBVFKeQQpF3rqwS IW31BJ8sQsRkJc/jgNY1Ip5eDIf2KjZc1Y9yV2ThGQX9OO/xGPAtQ/4vvzz1DPR13eEz EWLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=KfGaYCOUH2Is09EbvlUKiON2cwuL+lV8mdbBrSVpOsY=; b=HnyJdUMRrqO2s6JfJ138TK2WQqC+PCOm89aFtFzhJ6wNmCrg52NGuaVMSIKrp22Zw8 AP3xZwkaKnl0Nxgq4MCunEm4LkHyE1KgkBPvvYHZZJelt7V/IeTLQ8tfgAtLXfXYoWoX hzBuCLdkZMRR36wuhWeCjL1pzOOMt9nZbcxbApccd6s2xX7E2WSM7d7AcAJfPbUHTGV/ k11k1ha13mtBS1EoD5og1KooHJfQZLxH0vEOvULYmxXO5FoY1uBG75fEBnqQPOLEll1c zBgS5k3x1B+GhVQ0yZHwvSmkTsqzHC4cSuWITAGThVuZD6W8uEmTeDaVOqoZBDwBZebo c2/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j5r+GqsF; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f12-20020a056402068c00b004a226d65a10si18024335edy.49.2023.02.02.01.01.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:01:57 -0800 (PST) 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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j5r+GqsF; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F01AF3858428 for ; Thu, 2 Feb 2023 09:01:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F01AF3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675328516; bh=KfGaYCOUH2Is09EbvlUKiON2cwuL+lV8mdbBrSVpOsY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=j5r+GqsF5GuxV31YMlPmvlibJmSkCd4+4KKHcpIOy7I3Svb8e6UlQIKno0DE+cY4y yegu7Tz2lUpFNzin1M8yD9N2u/ung8rkYSJYHq2r7KXmd89GtTwA8m6bDC3stulx5x cU0vccU4M3WTkP1FxZbypo7C3M0HHAc54qI8gGLw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 C40703858C30 for ; Thu, 2 Feb 2023 09:00:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C40703858C30 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-XzlfEGouMoexPIpDHTujtg-1; Thu, 02 Feb 2023 04:00:58 -0500 X-MC-Unique: XzlfEGouMoexPIpDHTujtg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A98AF811E6E; Thu, 2 Feb 2023 09:00:57 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E780404CD80; Thu, 2 Feb 2023 09:00:57 +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 31290rlh1318815 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Feb 2023 10:00:54 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31290q311318814; Thu, 2 Feb 2023 10:00:52 +0100 Date: Thu, 2 Feb 2023 10:00:52 +0100 To: gcc-patches@gcc.gnu.org Cc: Tobias Burnus Subject: [committed] nested, openmp: Wrap OMP_CLAUSE_*_GIMPLE_SEQ into GIMPLE_BIND for declare_vars [PR108435] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1756709275443173138?= X-GMAIL-MSGID: =?utf-8?q?1756709275443173138?= Hi! When gimplifying OMP_CLAUSE_{LASTPRIVATE,LINEAR}_STMT, we wrap it always into a GIMPLE_BIND, but when putting statements directly into OMP_CLAUSE_{LASTPRIVATE,LINEAR}_GIMPLE_SEQ, we do it only if needed (there are any temporaries that need to be declared in the sequence). convert_nonlocal_omp_clauses was relying on the GIMPLE_BIND to be there always because it called declare_vars on it. The following patch wraps it into GIMPLE_BIND in tree-nested if we need to declare_vars on it on demand. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2023-02-02 Jakub Jelinek PR middle-end/108435 * tree-nested.cc (convert_nonlocal_omp_clauses) : If info->new_local_var_chain and *seq is not a GIMPLE_BIND, wrap the sequence into a new GIMPLE_BIND before calling declare_vars. (convert_nonlocal_omp_clauses) : Merge with the OMP_CLAUSE_LASTPRIVATE handling except for whether seq is initialized to &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause) or &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause). * gcc.dg/gomp/pr108435.c: New test. Jakub --- gcc/tree-nested.cc.jj 2023-01-02 09:32:40.110029184 +0100 +++ gcc/tree-nested.cc 2023-02-01 16:22:33.272248502 +0100 @@ -1566,29 +1566,29 @@ convert_nonlocal_omp_clauses (tree *pcla break; case OMP_CLAUSE_LASTPRIVATE: - { - tree save_local_var_chain = info->new_local_var_chain; - info->new_local_var_chain = NULL; - gimple_seq *seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause); - walk_body (convert_nonlocal_reference_stmt, - convert_nonlocal_reference_op, info, seq); - if (info->new_local_var_chain) - declare_vars (info->new_local_var_chain, - gimple_seq_first_stmt (*seq), false); - info->new_local_var_chain = save_local_var_chain; - } - break; - case OMP_CLAUSE_LINEAR: { tree save_local_var_chain = info->new_local_var_chain; info->new_local_var_chain = NULL; - gimple_seq *seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause); + gimple_seq *seq; + if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_LASTPRIVATE) + seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause); + else + seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause); walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op, info, seq); if (info->new_local_var_chain) - declare_vars (info->new_local_var_chain, - gimple_seq_first_stmt (*seq), false); + { + gimple *g = gimple_seq_first_stmt (*seq); + if (gimple_code (g) != GIMPLE_BIND) + { + g = gimple_build_bind (NULL_TREE, *seq, NULL_TREE); + *seq = NULL; + gimple_seq_add_stmt_without_update (seq, g); + } + declare_vars (info->new_local_var_chain, + gimple_seq_first_stmt (*seq), false); + } info->new_local_var_chain = save_local_var_chain; } break; --- gcc/testsuite/gcc.dg/gomp/pr108435.c.jj 2023-02-01 16:24:56.180152165 +0100 +++ gcc/testsuite/gcc.dg/gomp/pr108435.c 2023-02-01 16:24:36.150445983 +0100 @@ -0,0 +1,18 @@ +/* PR middle-end/108435 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp" } */ + +int +main () +{ + int i, j; + void + bar (void) + { + #pragma omp for simd collapse(2) + for (i = 1; i <= 16; i++) + for (j = 1; j <= 16; j++) + ; + } + bar (); +}