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 29177385AC1B for ; Mon, 5 Sep 2022 12:29:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 29177385AC1B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662380939; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=lziwNTelGxvcsnv4CyUh/QpioScHnX3uIcxuLkuM/L4=; b=euXgK+OR6SBYFSz+pZApttA5rZ29uGJswzh3b9988yLfd5k9KnURdRoq/gWH95AZRIPbs7 3+3u/SKiZw/dsFrZjmUcU/aIQZzh75Fu59Oe0qilnC7wiJtlHLdAC2TfgOE+opognMfuCM 8DRJHvCUiv890CXD77BRfj3+/8D5b48= 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-3-ygkrFQofOtOw2xxHBb18tg-1; Mon, 05 Sep 2022 08:28:58 -0400 X-MC-Unique: ygkrFQofOtOw2xxHBb18tg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 341F1803301; Mon, 5 Sep 2022 12:28:58 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6A152166B26; Mon, 5 Sep 2022 12:28: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 285CSsHa075382 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 5 Sep 2022 14:28:55 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 285CSrlk075381; Mon, 5 Sep 2022 14:28:53 +0200 Date: Mon, 5 Sep 2022 14:28:53 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, Tobias Burnus Subject: [PATCH] openmp: Introduce gimple_omp_ordered_standalone_p Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: Hi! On Sat, Sep 03, 2022 at 10:07:27AM +0200, Jakub Jelinek via Gcc-patches wrote: > Incrementally, I'd like to change the way we differentiate between > stand-alone and block-associated ordered constructs, because the current > way of looking for presence of doacross clause doesn't work well if those > clauses are removed because they had been invalid (wrong syntax or > unknown variables in it etc.) The following, so far only lightly tested, patch implements that. Will commit if it passes full bootstrap/regtest on x86_64-linux and i686-linux overnight. 2022-09-05 Jakub Jelinek gcc/ * gimple.h (enum gf_mask): Add GF_OMP_ORDERED_STANDALONE enumerator. (gimple_omp_subcode): Use GIMPLE_OMP_ORDERED instead of GIMPLE_OMP_TEAMS as upper bound. (gimple_omp_ordered_standalone_p, gimple_omp_ordered_standalone): New inline functions. * gimplify.cc (find_standalone_omp_ordered): Look for OMP_ORDERED with NULL OMP_ORDERED_BODY rather than with OMP_DOACROSS clause. (gimplify_expr): Call gimple_omp_ordered_standalone for OMP_ORDERED with NULL OMP_ORDERED_BODY. * omp-low.cc (check_omp_nesting_restrictions): Use gimple_omp_ordered_standalone_p test instead of omp_find_clause (..., OMP_CLAUSE_DOACROSS). (lower_omp_ordered): Likewise. * omp-expand.cc (expand_omp, build_omp_regions_1, omp_make_gimple_edges): Likewise. gcc/cp/ * pt.cc (tsubst_expr) : If OMP_BODY was NULL, keep it NULL after instantiation too. gcc/testsuite/ * c-c++-common/gomp/sink-3.c: Don't expect a superfluous error during error recovery. * c-c++-common/gomp/doacross-6.c (foo): Add further tests. --- gcc/gimple.h.jj 2022-06-27 11:18:02.682058403 +0200 +++ gcc/gimple.h 2022-09-05 13:47:21.009761168 +0200 @@ -194,6 +194,7 @@ enum gf_mask { GF_OMP_RETURN_NOWAIT = 1 << 0, GF_OMP_SECTION_LAST = 1 << 0, + GF_OMP_ORDERED_STANDALONE = 1 << 0, GF_OMP_ATOMIC_MEMORY_ORDER = (1 << 6) - 1, GF_OMP_ATOMIC_NEED_VALUE = 1 << 6, GF_OMP_ATOMIC_WEAK = 1 << 7, @@ -2312,7 +2313,7 @@ static inline unsigned gimple_omp_subcode (const gimple *s) { gcc_gimple_checking_assert (gimple_code (s) >= GIMPLE_OMP_ATOMIC_LOAD - && gimple_code (s) <= GIMPLE_OMP_TEAMS); + && gimple_code (s) <= GIMPLE_OMP_ORDERED); return s->subcode; } @@ -2402,6 +2403,27 @@ gimple_omp_section_set_last (gimple *g) } +/* Return true if OMP ordered construct is stand-alone + (G has the GF_OMP_ORDERED_STANDALONE flag set). */ + +static inline bool +gimple_omp_ordered_standalone_p (const gimple *g) +{ + GIMPLE_CHECK (g, GIMPLE_OMP_ORDERED); + return (gimple_omp_subcode (g) & GF_OMP_ORDERED_STANDALONE) != 0; +} + + +/* Set the GF_OMP_ORDERED_STANDALONE flag on G. */ + +static inline void +gimple_omp_ordered_standalone (gimple *g) +{ + GIMPLE_CHECK (g, GIMPLE_OMP_ORDERED); + g->subcode |= GF_OMP_ORDERED_STANDALONE; +} + + /* Return true if OMP parallel statement G has the GF_OMP_PARALLEL_COMBINED flag set. */ --- gcc/gimplify.cc.jj 2022-09-03 09:41:34.823006434 +0200 +++ gcc/gimplify.cc 2022-09-05 13:37:00.158143869 +0200 @@ -12427,7 +12427,7 @@ gimplify_omp_taskloop_expr (tree type, t } /* Helper function of gimplify_omp_for, find OMP_ORDERED with - OMP_CLAUSE_DOACROSS clause inside of OMP_FOR's body. */ + null OMP_ORDERED_BODY inside of OMP_FOR's body. */ static tree find_standalone_omp_ordered (tree *tp, int *walk_subtrees, void *) @@ -12435,7 +12435,7 @@ find_standalone_omp_ordered (tree *tp, i switch (TREE_CODE (*tp)) { case OMP_ORDERED: - if (omp_find_clause (OMP_ORDERED_CLAUSES (*tp), OMP_CLAUSE_DOACROSS)) + if (OMP_ORDERED_BODY (*tp) == NULL_TREE) return *tp; break; case OMP_SIMD: @@ -15839,6 +15839,9 @@ gimplify_expr (tree *expr_p, gimple_seq break; case OMP_ORDERED: g = gimplify_omp_ordered (*expr_p, body); + if (OMP_BODY (*expr_p) == NULL_TREE + && gimple_code (g) == GIMPLE_OMP_ORDERED) + gimple_omp_ordered_standalone (g); break; case OMP_MASKED: gimplify_scan_omp_clauses (&OMP_MASKED_CLAUSES (*expr_p), --- gcc/omp-low.cc.jj 2022-09-03 09:41:34.827006378 +0200 +++ gcc/omp-low.cc 2022-09-05 13:24:30.796236971 +0200 @@ -3718,7 +3718,7 @@ check_omp_nesting_restrictions (gimple * "a loop region with an % clause"); return false; } - if (omp_find_clause (c, OMP_CLAUSE_DOACROSS) == NULL_TREE) + if (!gimple_omp_ordered_standalone_p (stmt)) { if (OMP_CLAUSE_ORDERED_DOACROSS (o)) { @@ -9989,8 +9989,7 @@ lower_omp_ordered (gimple_stmt_iterator bool threads = omp_find_clause (gimple_omp_ordered_clauses (ord_stmt), OMP_CLAUSE_THREADS); - if (omp_find_clause (gimple_omp_ordered_clauses (ord_stmt), - OMP_CLAUSE_DOACROSS)) + if (gimple_omp_ordered_standalone_p (ord_stmt)) { /* FIXME: This is needs to be moved to the expansion to verify various conditions only testable on cfg with dominators computed, and also --- gcc/omp-expand.cc.jj 2022-09-03 09:41:34.829006350 +0200 +++ gcc/omp-expand.cc 2022-09-05 13:25:39.328317824 +0200 @@ -10487,8 +10487,7 @@ expand_omp (struct omp_region *region) { gomp_ordered *ord_stmt = as_a (last_stmt (region->entry)); - if (omp_find_clause (gimple_omp_ordered_clauses (ord_stmt), - OMP_CLAUSE_DOACROSS)) + if (gimple_omp_ordered_standalone_p (ord_stmt)) { /* We'll expand these when expanding corresponding worksharing region with ordered(n) clause. */ @@ -10616,9 +10615,7 @@ build_omp_regions_1 (basic_block bb, str } } else if (code == GIMPLE_OMP_ORDERED - && omp_find_clause (gimple_omp_ordered_clauses - (as_a (stmt)), - OMP_CLAUSE_DOACROSS)) + && gimple_omp_ordered_standalone_p (stmt)) /* #pragma omp ordered depend is also just a stand-alone directive. */ region = NULL; @@ -10842,9 +10839,7 @@ omp_make_gimple_edges (basic_block bb, s case GIMPLE_OMP_ORDERED: cur_region = new_omp_region (bb, code, cur_region); fallthru = true; - if (omp_find_clause (gimple_omp_ordered_clauses - (as_a (last)), - OMP_CLAUSE_DOACROSS)) + if (gimple_omp_ordered_standalone_p (last)) cur_region = cur_region->outer; break; --- gcc/cp/pt.cc.jj 2022-09-03 09:41:34.866005829 +0200 +++ gcc/cp/pt.cc 2022-09-05 14:16:25.584362892 +0200 @@ -19526,9 +19526,14 @@ tsubst_expr (tree t, tree args, tsubst_f case OMP_ORDERED: tmp = tsubst_omp_clauses (OMP_ORDERED_CLAUSES (t), C_ORT_OMP, args, complain, in_decl); - stmt = push_stmt_list (); - RECUR (OMP_BODY (t)); - stmt = pop_stmt_list (stmt); + if (OMP_BODY (t)) + { + stmt = push_stmt_list (); + RECUR (OMP_BODY (t)); + stmt = pop_stmt_list (stmt); + } + else + stmt = NULL_TREE; t = copy_node (t); OMP_BODY (t) = stmt; --- gcc/testsuite/c-c++-common/gomp/sink-3.c.jj 2022-09-03 09:41:34.928004956 +0200 +++ gcc/testsuite/c-c++-common/gomp/sink-3.c 2022-09-05 14:07:04.580887813 +0200 @@ -14,7 +14,7 @@ foo () for (i=0; i < 100; ++i) { #pragma omp ordered depend(sink:poo-1,paa+1) /* { dg-error "poo.*declared.*paa.*declared" } */ - bar(&i); /* { dg-error "must not have the same binding region" "" { target *-*-* } .-1 } */ + bar(&i); #pragma omp ordered depend(source) } } --- gcc/testsuite/c-c++-common/gomp/doacross-6.c.jj 2022-09-03 09:41:34.914005153 +0200 +++ gcc/testsuite/c-c++-common/gomp/doacross-6.c 2022-09-05 13:34:20.545312759 +0200 @@ -22,6 +22,18 @@ foo (int n) { #pragma omp ordered doacross(sink) /* { dg-error "expected ':' before '\\\)' token" } */ } + #pragma omp for ordered + for (i = 0; i < 8; i += n) + { + #pragma omp ordered doacross(source) /* { dg-error "expected ':' before '\\\)' token" } */ + #pragma omp ordered doacross(sink:i-1) + } + #pragma omp for ordered + for (i = 0; i < 8; i += n) + { + #pragma omp ordered doacross(source:) + #pragma omp ordered doacross(sink) /* { dg-error "expected ':' before '\\\)' token" } */ + } } void Jakub