From patchwork Tue Aug 9 13:23:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:20da:b0:2d3:3019:e567 with SMTP id n26csp2515727pxc; Tue, 9 Aug 2022 06:25:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4cjMPnAYRQOhw7ol0uTWKp0Qj33UD2XY8IFaW4lZ2oC8Y5uK3y9zOcSo5WTBVspDHQFXmi X-Received: by 2002:a05:6402:2b8d:b0:43a:5410:a9fc with SMTP id fj13-20020a0564022b8d00b0043a5410a9fcmr22467959edb.99.1660051549701; Tue, 09 Aug 2022 06:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660051549; cv=none; d=google.com; s=arc-20160816; b=ZLzazk0TiMBbbPhXT+0jo2vCl9VxsHavOEY5a3XCQgaZiEy48Fc0v1W6LEO7rnYhXt cdw86wmnDY2QfSd8atUzQCYSVmaOIEs73dYS/94F3aL5zacpzRoRKSJqlvMDxlYcWY0U XNJwUFBjJ2C1ES+UoPZs8XcLwAPnypi8A2Zz5AhZNTVhk5GHJapRl8Ggi4ArJmMAQAW/ DjZeZct8bItDg1wpgp0m0SNlp+fRq5BLsQfcMMBpBvEs+Zh25JbBYVeTkPMUlnoROv7C vjMjkKAPWY/n7S7Fw6va9e/jG0fb3lGOutSQdgrCzWh1RUGIg59Nm6dapsgPqxHzi5S3 kw0w== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :ironport-sdr:dmarc-filter:delivered-to; bh=XKyem1nAUo1n7Zx02p2EInlGtRfZsOZcBB5tlNTKIWo=; b=urnItwa3MoaIX0BRZObjV04E0wt0dVXw2xnFe9xGGNtGYJdjpV2PT+2+T9gMtW/kHE DwC2z+VjV5Jyl1obl2BviRszHyrZyXlmlt1pGmH9ruzv2WrmB079kMKKbgz7m2EZAb92 MD3er42TTWwKmz6bVGdVt4aFMMMLgAVPfl6hunYitf+kHLiFmluIgWS4LFvdTj+vvaqq th2/EEvNtHReedJWj59rAod8vHvxu+A8330ixZ+VqrTzfEUeFk88dq5uUymucasdwfFw ThdZiXywawJniKVO4gVNI/vsKhlridjUWyqI6IOXzOR3qckNQlO/4CCLY2gy7aFSyG49 sK3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hd33-20020a17090796a100b00732fa7c5058si1096209ejc.300.2022.08.09.06.25.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 06:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 2C4963856262 for ; Tue, 9 Aug 2022 13:25:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 6049E3856DE2 for ; Tue, 9 Aug 2022 13:24:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6049E3856DE2 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,224,1654588800"; d="scan'208";a="80994424" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 09 Aug 2022 05:24:13 -0800 IronPort-SDR: kYUeIiRu+kzynfRQvftP/SMnw869ClMTQ3s9QZ6bs6R0f//EJZReNLdwDC4r8Zn10q7UE1kL+A WkU1bZM/bXJj++OqAVYoQR8oeQfiOGl3JxynO8/aGN64Hs9M8TG9DmEgf08bImpSLwxMz5ZEAK 9j9FmeUm2I8rW4yDXWy39tMDK47G9VvMU5q37uszBC6VUzrcO0hYd/bi8eGWRuKECPV9My6G/n 1b9R9jX9SrUbAb3gge1Zl2MB9wevDQLbhY686mWYwl2YUgQgagowgdWf+QInIKo1F+n61//+1/ EBw= From: Andrew Stubbs To: Subject: [PATCH 2/3] amdgcn: OpenMP SIMD routine support Date: Tue, 9 Aug 2022 14:23:49 +0100 Message-ID: X-Mailer: git-send-email 2.37.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: , 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?1740690213470280558?= X-GMAIL-MSGID: =?utf-8?q?1740690213470280558?= Enable and configure SIMD clones for amdgcn. This affects both the __simd__ function attribute, and the OpenMP "declare simd" directive. Note that the masked SIMD variants are generated, but the middle end doesn't actually support calling them yet. gcc/ChangeLog: * config/gcn/gcn.cc (gcn_simd_clone_compute_vecsize_and_simdlen): New. (gcn_simd_clone_adjust): New. (gcn_simd_clone_usable): New. (TARGET_SIMD_CLONE_ADJUST): New. (TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN): New. (TARGET_SIMD_CLONE_USABLE): New. gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-simd-clone-1.c: Add dg-warning. * gcc.dg/vect/vect-simd-clone-2.c: Add dg-warning. * gcc.dg/vect/vect-simd-clone-3.c: Add dg-warning. * gcc.dg/vect/vect-simd-clone-4.c: Add dg-warning. * gcc.dg/vect/vect-simd-clone-5.c: Add dg-warning. * gcc.dg/vect/vect-simd-clone-8.c: Add dg-warning. --- gcc/config/gcn/gcn.cc | 63 +++++++++++++++++++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-1.c | 2 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-2.c | 2 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-3.c | 1 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-4.c | 1 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-5.c | 1 + gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c | 2 + 7 files changed, 72 insertions(+) diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index 96295e23aad..ceb69000807 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -52,6 +52,7 @@ #include "rtl-iter.h" #include "dwarf2.h" #include "gimple.h" +#include "cgraph.h" /* This file should be included last. */ #include "target-def.h" @@ -4555,6 +4556,61 @@ gcn_vectorization_cost (enum vect_cost_for_stmt ARG_UNUSED (type_of_cost), return 1; } +/* Implement TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN. */ + +static int +gcn_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *ARG_UNUSED (node), + struct cgraph_simd_clone *clonei, + tree base_type, + int ARG_UNUSED (num)) +{ + unsigned int elt_bits = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type)); + + if (known_eq (clonei->simdlen, 0U)) + clonei->simdlen = 64; + else if (maybe_ne (clonei->simdlen, 64U)) + { + /* Note that x86 has a similar message that is likely to trigger on + sizes that are OK for gcn; the user can't win. */ + warning_at (DECL_SOURCE_LOCATION (node->decl), 0, + "unsupported simdlen %wd (amdgcn)", + clonei->simdlen.to_constant ()); + return 0; + } + + clonei->vecsize_mangle = 'n'; + clonei->vecsize_int = 0; + clonei->vecsize_float = 0; + + /* DImode ought to be more natural here, but VOIDmode produces better code, + at present, due to the shift-and-test steps not being optimized away + inside the in-branch clones. */ + clonei->mask_mode = VOIDmode; + + return 1; +} + +/* Implement TARGET_SIMD_CLONE_ADJUST. */ + +static void +gcn_simd_clone_adjust (struct cgraph_node *ARG_UNUSED (node)) +{ + /* This hook has to be defined when + TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN is defined, but we don't + need it to do anything yet. */ +} + +/* Implement TARGET_SIMD_CLONE_USABLE. */ + +static int +gcn_simd_clone_usable (struct cgraph_node *ARG_UNUSED (node)) +{ + /* We don't need to do anything here because + gcn_simd_clone_compute_vecsize_and_simdlen currently only returns one + possibility. */ + return 0; +} + /* }}} */ /* {{{ md_reorg pass. */ @@ -6643,6 +6699,13 @@ gcn_dwarf_register_span (rtx rtl) #define TARGET_SECTION_TYPE_FLAGS gcn_section_type_flags #undef TARGET_SCALAR_MODE_SUPPORTED_P #define TARGET_SCALAR_MODE_SUPPORTED_P gcn_scalar_mode_supported_p +#undef TARGET_SIMD_CLONE_ADJUST +#define TARGET_SIMD_CLONE_ADJUST gcn_simd_clone_adjust +#undef TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN +#define TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN \ + gcn_simd_clone_compute_vecsize_and_simdlen +#undef TARGET_SIMD_CLONE_USABLE +#define TARGET_SIMD_CLONE_USABLE gcn_simd_clone_usable #undef TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \ gcn_small_register_classes_for_mode_p diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-1.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-1.c index 50429049500..cd65fc343f1 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-1.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-1.c @@ -56,3 +56,5 @@ main () return 0; } +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */ +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-2.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-2.c index f89c73a961b..ffcbf9380d6 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-2.c @@ -50,3 +50,5 @@ main () return 0; } +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */ +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 18 } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-3.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-3.c index 75ce696ed66..18d68779cc5 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-3.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-3.c @@ -43,3 +43,4 @@ main () return 0; } +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 15 } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-4.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-4.c index debbe77b79d..e9af0b83162 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-4.c @@ -46,3 +46,4 @@ main () return 0; } +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 17 } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-5.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-5.c index 6a098d9a51a..46da496524d 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-5.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-5.c @@ -41,3 +41,4 @@ main () return 0; } +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } 15 } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c index 1bfd19dc8ab..f414285a170 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c @@ -92,3 +92,5 @@ main () return 0; } +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 17 } */ +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } 24 } */