From patchwork Mon Feb 10 18:07:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 106295 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70AF6385772D for ; Mon, 10 Feb 2025 18:14:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70AF6385772D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=iJgKnh3U X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 965023858288 for ; Mon, 10 Feb 2025 18:07:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 965023858288 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 965023858288 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739210867; cv=none; b=expgAewwhy3mAXxC/KQa/VlYO+Vy18b1j9NoPTkLlNsrI/9Gv1uowj9Jb8DR33yrQiGKnDyAZocdnlgZOIh5zCg8OmmT+d2WyHhsVgCKfwk9YOxKNvsC0eU98TNQwL8x9ai1CsdI1png13rHDEzAM9+lo9hddP809/nGVw9yPTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739210867; c=relaxed/simple; bh=fdQiP/zm5xMwV0migcQMDKVmco2kd403IY/mvjR/5CM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Y0ekeBQIoL9BX2UJJTK0dnm74h4kgF3OLddPnJ1Q7Jp+UlOYmT5sWmnWUHzGej3slp+eN02vNJqF5AAorjdeT02zZxIdSC1BDjRokJ7pwZGsrjMKjoMgEAKpIz+RQwaqONqSSG/G3SSv71Jc1OTBLdHzOoQT+Y8wHgUFPaB+qR4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 965023858288 Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-3cfc79a8a95so15587035ab.2 for ; Mon, 10 Feb 2025 10:07:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1739210866; x=1739815666; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VCbXbykSwKCpz+zpTOrBLzyJsYHFrsEwdF7+KVjfaxM=; b=iJgKnh3UtuJfAJypL0xM6P/eCKZ6i32CzSf6SKuZrC/uraalpX74aBzCXoI3G9Qs7Y 4uK8VvZl/n2DlzvccRSWJ7G4iplrat3zLe2ONnLJNURK6AQoO5jeNIMfrqEk/Ntb52tK WgvBb/sRdeJodscl003uYWRnq5zOiDsbAtG2VGEGsm0z2J3Q0qyxji+4sSzC0gdHmFeB GOizS5FwCsGJnQF1Vc4/xrORIy1OtUVG0L+4gorlPyWvKYSQWa7Jfvzthqyjnzpy4qwN 5AnEcrP7mxgs6ekM+s8m3Olji7EFQMLIrWJPDFz1e2e7zOxVETGusIYqg6Lt31nZ3HH2 wBhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739210866; x=1739815666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VCbXbykSwKCpz+zpTOrBLzyJsYHFrsEwdF7+KVjfaxM=; b=XruA9/ujJF+N/yc1T6uCiKBR3ZyGWWJMQW1GKtN2HEgYDCjtrCajnVPJ8SDP74I8Sr 276yVqOCeHDotGsNyzqdwjCthr2zbxN5iVPrsoTPfxvWSjUWMbAgZ7xfKg3xe44C11rF hLVVrWUYBzYIV0tD8n0TBxL8THXeEcIe3OZkb6GwSAdiKK3amP6G/HLvy/AweoNBc9d2 MaNsohoFMfcZdSKNfCpoBvzfBRAvd7zHpmGTztRrvjVr+HWhqGqmzmuODK1S/Sbis4Lr KMkxqGu8cdoflSUd3JsH/8zHSoJZhCYqw72q8WGnfp/aSoOarku+YGCxWb3z0HXoDXJv Kocg== X-Gm-Message-State: AOJu0YzJsbx6PMZz1SIX7QgV1wOo5EiPznKl0R7E+6HZHm7ShiCJUEvq VpbXdDikodoj9OBtBRvc4qLiMLD4oHnLolnJOBkLgaXQbrxV/1r31s0XIh5zgWxQwUPohDN9QOq q X-Gm-Gg: ASbGnctT9uNrA0UfojnvknbrAyZP3Ypkya0ZkE56ZCV3p92HkdZyCZpcNt99U3PRrtX +pVwQm8GRjY2MH9jtAUMvq7pE24moCIQwZJKDK+a+ZER3nd2V5xwnDUVuaoniChdvfv/udF7K5S 8FfK8vgpTVZwiZNzNBgjDn5UKEVr63QlCtHo/4Gi+QUsHlQKznYqCZG0jpbgLBmqSg5VyYr50Yx ibh7BtBR0oalNWSoAl/pv6bljRtD/71uqqmEAXM0tys9DWUxTyHCSWKpsVtQazU8Hqj5VWDYfZS o5nP2LPxfWW0GimomlTmOOweNzI= X-Google-Smtp-Source: AGHT+IE5GvgCXaD/nY8m9ObBvE+Er+V1K827mGDTgV4V4T5K11LU82vV3kaCpvOun85aJ2bGmQq68g== X-Received: by 2002:a05:6e02:20c8:b0:3d0:21aa:a752 with SMTP id e9e14a558f8ab-3d13dd2c035mr111193375ab.2.1739210866403; Mon, 10 Feb 2025 10:07:46 -0800 (PST) Received: from pondscum.hsd1.co.comcast.net ([2601:281:d901:97c0::af71]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3d13d83c967sm19615365ab.45.2025.02.10.10.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 10:07:45 -0800 (PST) From: Sandra Loosemore To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com, tburnus@baylibre.com Subject: [PATCH 4/7] OpenMP: Add flag for code elision to omp_context_selector_matches. Date: Mon, 10 Feb 2025 11:07:22 -0700 Message-Id: <20250210180725.2076678-5-sloosemore@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250210180725.2076678-1-sloosemore@baylibre.com> References: <20250210180725.2076678-1-sloosemore@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org The "begin declare variant" has different rules for determining whether a context selector cannot match for purposes of code elision than we normally use; it excludes the case of a constant false "condition" selector for the "user" set. gcc/ChangeLog * omp-general.cc (omp_context_selector_matches): Add an optional bool argument for the code elision case. * omp-general.h (omp_context_selector_matches): Likewise. --- gcc/omp-general.cc | 28 ++++++++++++++++++++++++---- gcc/omp-general.h | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc index c7b8e17d1f7..2edc0a65abf 100644 --- a/gcc/omp-general.cc +++ b/gcc/omp-general.cc @@ -1735,13 +1735,19 @@ omp_construct_traits_match (tree selector_traits, tree context_traits, CONSTRUCT_CONTEXT is known to be complete and not missing constructs filled in later during compilation. + If DECLARE_VARIANT_ELISION_P is true, the function implements the test + for elision of preprocessed code in "begin declare variant" constructs, + and returns 0 only for failure to match traits in the device and + implementation sets. + Dynamic properties (which are evaluated at run-time) should always return 1. */ int omp_context_selector_matches (tree ctx, tree construct_context, - bool complete_p) + bool complete_p, + bool declare_variant_elision_p) { int ret = 1; bool maybe_offloaded = omp_maybe_offloaded (construct_context); @@ -1753,9 +1759,12 @@ omp_context_selector_matches (tree ctx, /* Immediately reject the match if there are any ignored selectors present. */ - for (tree ts = selectors; ts; ts = TREE_CHAIN (ts)) - if (OMP_TS_CODE (ts) == OMP_TRAIT_INVALID) - return 0; + if (!declare_variant_elision_p + || set == OMP_TRAIT_SET_DEVICE + || set == OMP_TRAIT_SET_IMPLEMENTATION) + for (tree ts = selectors; ts; ts = TREE_CHAIN (ts)) + if (OMP_TS_CODE (ts) == OMP_TRAIT_INVALID) + return 0; if (set == OMP_TRAIT_SET_CONSTRUCT) { @@ -2109,6 +2118,13 @@ omp_context_selector_matches (tree ctx, break; case OMP_TRAIT_USER_CONDITION: gcc_assert (set == OMP_TRAIT_SET_USER); + /* The spec does not include the "user" set in the things that + can trigger code elision in "begin declare variant". */ + if (declare_variant_elision_p) + { + ret = -1; + break; + } for (tree p = OMP_TS_PROPERTIES (ts); p; p = TREE_CHAIN (p)) if (OMP_TP_NAME (p) == NULL_TREE) { @@ -2124,6 +2140,10 @@ omp_context_selector_matches (tree ctx, ret = -1; } break; + case OMP_TRAIT_INVALID: + /* This is only for the declare_variant_elision_p case. */ + ret = -1; + break; default: break; } diff --git a/gcc/omp-general.h b/gcc/omp-general.h index 466a70c9485..ec5a40fe6fa 100644 --- a/gcc/omp-general.h +++ b/gcc/omp-general.h @@ -205,7 +205,7 @@ extern bool omp_check_for_duplicate_variant (location_t loc, tree base_decl, tree ctx); extern void omp_mark_declare_variant (location_t loc, tree variant, tree construct); -extern int omp_context_selector_matches (tree, tree, bool); +extern int omp_context_selector_matches (tree, tree, bool, bool = false); extern tree omp_merge_context_selectors (location_t, tree, tree, enum omp_ctx_directive); extern tree resolve_omp_target_device_matches (tree node);