From patchwork Mon Oct 23 07:22:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 156695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1127653vqx; Mon, 23 Oct 2023 00:24:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeUHfI8RHtrMSXKPpvlFq2Sr9aNDJYBglgjGZ9HnZYBufMdyKUW0vwrj+g8r0hEGoq+DkS X-Received: by 2002:ac8:5fc9:0:b0:41c:cda8:9981 with SMTP id k9-20020ac85fc9000000b0041ccda89981mr10912265qta.64.1698045873496; Mon, 23 Oct 2023 00:24:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698045873; cv=pass; d=google.com; s=arc-20160816; b=RF83Eb/gV5fc02EqqZ2PZu7CHIcKk6W9oxVQme4kasAeh/t2yirdbjGtgmz2gZ/UOX uI6n/kh2CPxnAW49yGNtxfiAbk1VUJh1ho2TgQRuPiazmysULSCof3GbPNhmV/iSZUxL CGdw8+ap0ULHbQ+gYk59PtAy4pK47fXPvfvFi/JPAHws0DSJl5tzSc1sovpcgyFtQkCg fsCr87ZsqE8FDMJRsgcbAxF5t/g7aqUBUVmSh5ADBqzU3WUFgGuMNKKHu4VMwRWUb5wl c8/mkAdFUgofh5d3PoMpWjFBf0vXg7uA7heIwcXEwQX9DJ54RXiCb17NL2+tPHlg/8Tc SRTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Ou+C/f0nUEjEAmwvrJe5pRB/WhfOhGmJkEf+zoVJ51M=; fh=HKgiOHUFLyfVG2npWMLYE8/3Ecp4EiEdadhQOzpm3aI=; b=H0pIz+8WkmT/yGTOZxHLqD7kc4D/8BH+j2J5/+mmdEu+IrYLHl4QecoiS033M7FCn1 gJcZnt9U0PR6NGZdrMCmX6No5zykQg22hFYh/3kwMYDVaCch+IxxbwfPAiWmk4phCR6Q yYiL7/LPNCcQFluai9bEEIUMCPXTmdVji70WraPkr1mEVDMPm65NIq2WKrAM7oftkbFx M2P996j4sy6pHVHjXIS9tTov4JrhJvySD09UC6MsZiSHuFYsY+gT5CpgHZeh4LvBhg7Y td8QMwvDuZgXjP50UE+EWwPjT5GeRNKZjsG+uDROxmAkywq91KrfENlJRa+JMbl6+/GD 5P2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=f7f3Qi2f; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w3-20020a05622a190300b004195aa3bc1dsi5269427qtc.577.2023.10.23.00.24.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 00:24:33 -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; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=f7f3Qi2f; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7593C3857029 for ; Mon, 23 Oct 2023 07:24:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 3D03D3858422 for ; Mon, 23 Oct 2023 07:24:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D03D3858422 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3D03D3858422 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=153.120.152.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045843; cv=none; b=e0BWHFb+di/UcXiyvoHmtfx6g5+VB9UEBSfcXaCP01cxMp+I6BRjnw+Eo85vsod+HoF63GEkfyuSoi/NAVAyAmkDowwmyzFsjpgNOOg5h/l8h8Gne4YG+RV8r1LSmJXxMI2tcTlpPmB76HYkjgGM/JW1nYNxjkYvOM2JU6lZQNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045843; c=relaxed/simple; bh=csSYW9Cz248rLEro8+aUdW2MoMKCyBncF9cK/lGcgKU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=CRIxWmtz2ct7p3iGzODgriQUKEZQ1U9eoQA3NP2ZIFlI4SL6KrkiGBE9+RAnlgZVXakSuzC5CB8UFuuxDDinWT/gEu7bYcmWIrDV14qa2lbIJFvQEu9vCxsBONBN9fMSO6yTV6UGYUHeJOmzpq6h33izgto6+ZZyAEZcf3dxoYo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 4614D300089; Mon, 23 Oct 2023 07:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1698045840; bh=Ou+C/f0nUEjEAmwvrJe5pRB/WhfOhGmJkEf+zoVJ51M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=f7f3Qi2fk4kGExUuZ+IYx4ElGADJL12v5kReCrGrccpgadHw8d+PuRhDB74IF/6Yd Xs2yhSBOX37kOxNy+z11lj3AAM88wIzwe/6gHPnM/ssERouj2tlkAvF61/yn1XYW9Z 2FIswLXgdxqEfUxxQOT5jS/qyfhNxdqYfKwoX5nQ= From: Tsukasa OI To: Tsukasa OI , Kito Cheng , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 1/4] RISC-V: Recategorize "prefetch" availabilities Date: Mon, 23 Oct 2023 07:22:52 +0000 Message-ID: In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_MANYTO, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780530149886387032 X-GMAIL-MSGID: 1780530149886387032 From: Tsukasa OI Because they are for all prefetch instructions, "prefetch" fits better than "prefetchi". gcc/ChangeLog: * config/riscv/riscv-builtins.cc: Rename availabilities "prefetchi{32,64}" to "prefetch{32,64}". * config/riscv/riscv-cmo.def (__builtin_riscv_zicbop_cbo_prefetchi): Reflect availability name changes. --- gcc/config/riscv/riscv-builtins.cc | 4 ++-- gcc/config/riscv/riscv-cmo.def | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/config/riscv/riscv-builtins.cc b/gcc/config/riscv/riscv-builtins.cc index fc3976f3ba12..ce549eb3782d 100644 --- a/gcc/config/riscv/riscv-builtins.cc +++ b/gcc/config/riscv/riscv-builtins.cc @@ -103,8 +103,8 @@ AVAIL (inval32, TARGET_ZICBOM && !TARGET_64BIT) AVAIL (inval64, TARGET_ZICBOM && TARGET_64BIT) AVAIL (zero32, TARGET_ZICBOZ && !TARGET_64BIT) AVAIL (zero64, TARGET_ZICBOZ && TARGET_64BIT) -AVAIL (prefetchi32, TARGET_ZICBOP && !TARGET_64BIT) -AVAIL (prefetchi64, TARGET_ZICBOP && TARGET_64BIT) +AVAIL (prefetch32, TARGET_ZICBOP && !TARGET_64BIT) +AVAIL (prefetch64, TARGET_ZICBOP && TARGET_64BIT) AVAIL (crypto_zbkb32, TARGET_ZBKB && !TARGET_64BIT) AVAIL (crypto_zbkb64, TARGET_ZBKB && TARGET_64BIT) AVAIL (crypto_zbkx32, TARGET_ZBKX && !TARGET_64BIT) diff --git a/gcc/config/riscv/riscv-cmo.def b/gcc/config/riscv/riscv-cmo.def index ff713b78e19e..017370d1d0e3 100644 --- a/gcc/config/riscv/riscv-cmo.def +++ b/gcc/config/riscv/riscv-cmo.def @@ -13,8 +13,8 @@ RISCV_BUILTIN (zero_si, "zicboz_cbo_zero", RISCV_BUILTIN_DIRECT_NO_TARGET, RISCV RISCV_BUILTIN (zero_di, "zicboz_cbo_zero", RISCV_BUILTIN_DIRECT_NO_TARGET, RISCV_VOID_FTYPE_VOID_PTR, zero64), // zicbop -RISCV_BUILTIN (prefetchi_si, "zicbop_cbo_prefetchi", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI, prefetchi32), -RISCV_BUILTIN (prefetchi_di, "zicbop_cbo_prefetchi", RISCV_BUILTIN_DIRECT, RISCV_UDI_FTYPE_UDI, prefetchi64), +RISCV_BUILTIN (prefetchi_si, "zicbop_cbo_prefetchi", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI, prefetch32), +RISCV_BUILTIN (prefetchi_di, "zicbop_cbo_prefetchi", RISCV_BUILTIN_DIRECT, RISCV_UDI_FTYPE_UDI, prefetch64), // zbkc or zbc RISCV_BUILTIN (clmul_si, "clmul", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI_USI, clmul_zbkc32_or_zbc32), From patchwork Mon Oct 23 07:22:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 156696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1127736vqx; Mon, 23 Oct 2023 00:24:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJ4hiVT3Cc9BBX0dYPLlh6fxXbjIQatvL0wcEylyJVlqukaRIz7/05gHX+bgP7tovrzP1h X-Received: by 2002:a05:6830:2b2a:b0:6c4:9fda:a1e2 with SMTP id l42-20020a0568302b2a00b006c49fdaa1e2mr7615432otv.4.1698045892427; Mon, 23 Oct 2023 00:24:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698045892; cv=pass; d=google.com; s=arc-20160816; b=Y3g2rrf+nrWlP5hnQWyzEo6oUum36tzCJuUmMk/PuwEVSeKL0oIM2m+PyXQC2YEg/R c1ARgJIScOpTMQsK6grVLDsYdMelHKM5tWiS2GjrJVwfevPxcdBvQUs8xAMY7ujHo+w4 VgmMOM0ZETxU4BWFK54tyrbswZVBVJ9mlk+UH0uWqfhdS73Ll58hNrnjk+4RSfHu+3cN cQHXpH06nQijjFIuHH/IkHbm6JTo0rmcN3E/KQnxzBK6Nv1Nm8MdiHsi9fYji9pmTlqt Rvnra7FQwGB71Eq+RLYNMQQV4Lr8DCfrWMyOk4ne4U8+IboNCrJBJ4zrEM9LkT4f8Y+f yt+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=/sByrfCqrpew7oPmI2LSfvIOCwoFsZr3LOzXBRvp3Pw=; fh=HKgiOHUFLyfVG2npWMLYE8/3Ecp4EiEdadhQOzpm3aI=; b=yGtu9KrCzVrvpn8ZKT9TzPQFnTWAiM9N5v/CrQ8bWcaYlt3j1mt8zMo4twt+c0rdtr UHgDFJbyiuDy1tyfw6XDBzsx9As/qAPOrGCztV+Y6yp10aShCJFqRwIGuqlRGaWE1img Tc5jAbpRYcW2e/0o4aycq9TZBUV/Gd6zIBT8yXisscbLnP5lenV0YmLG+ThjYtViH0Cr 2NJJFyTQz+CLjQdD1GUJ5SBTFX4HW5ZgSQwaTFF011CC5wehKuIJgQjMOivg7IyDxYBb YDi6Uq9/vbx30gMlhyN7daNzX8Z6Kp6J4LWKzZAO2Vhgi+vr4goMAiWo11jbJ8C0k1Yt 7dvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=DIRBwGXS; arc=pass (i=1); 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=irq.a4lg.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s19-20020a05622a179300b004181127a232si5148865qtk.651.2023.10.23.00.24.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 00:24:52 -0700 (PDT) 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=@irq.a4lg.com header.s=2017s01 header.b=DIRBwGXS; arc=pass (i=1); 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=irq.a4lg.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50E363861938 for ; Mon, 23 Oct 2023 07:24:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id F0F033857806 for ; Mon, 23 Oct 2023 07:24:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0F033857806 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F0F033857806 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=153.120.152.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045854; cv=none; b=SEG8IXVkXN9W5+HA+7/M10Ynm3BQQYisba6YDkzxtV1ZNH50CK+AtzDLW17jJ4dgWtPOLqHc3c4pCQPGbrz0PbkAnlaON6c86IZz40txGz1BWf2lsFJdy5kDaxV3IC+slvjgGbNjqvZ9gpcy/9D6xCXNZd6ebgSYN+1NJhI3s0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045854; c=relaxed/simple; bh=TPJyI7T6QGh26ngygK2EMlwu0c0W51fIvfuzy4QlDb8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=cAdB/EoeLxR1IodhXnUyXshWuFFsQRt62SurQwkq6d9C3kdwfvA21EQzv3Zqh8vwmDBGYsq2kZcWuaYjdR5jNxJBSNwhKYsOsCZRDrrDrOE04JTYK4KtqziAwEo++yIiTJnskDXmrgcmYjeYoRbnlAnMov9wLphqWR1uqsGtArI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 10C63300089; Mon, 23 Oct 2023 07:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1698045851; bh=/sByrfCqrpew7oPmI2LSfvIOCwoFsZr3LOzXBRvp3Pw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=DIRBwGXSUesomGE6HoT1LGKNp7q4arJ9LJE4UQyHjEh3wAwmhXD0BSvpiBsmwcLOD HlUTQV7jiUkHNl9v339ZjV9OgHeey05ayARbukrumsP23cGpQDokf8J7xk+wkIiNEg Jr5EgmQF+MuLcn7pZUmwhi0/ZRrN/2sbjaHwfAAk= From: Tsukasa OI To: Tsukasa OI , Kito Cheng , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 2/4] RISC-V: Remove broken __builtin_riscv_zicbop_cbo_prefetchi Date: Mon, 23 Oct 2023 07:22:53 +0000 Message-ID: <68ebe422ceb2c408006b2acab94de569cf8d0e78.1698045769.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_MANYTO, KAM_SHORT, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780530169617896313 X-GMAIL-MSGID: 1780530169617896313 From: Tsukasa OI __builtin_riscv_zicbop_cbo_prefetchi (corresponding "prefetch.i" instruction from the 'Zicbop' extension) is completely broken (not even functional) and should be removed rather than fixing it because it has no good way to "fix" this built-in function. gcc/ChangeLog: * config/riscv/riscv-cmo.def (__builtin_riscv_zicbop_cbo_prefetchi): Remove since it's broken. * config/riscv/riscv.md (unspecv) Remove UNSPECV_PREI. (riscv_prefetchi_): Remove. gcc/testsuite/ChangeLog: * gcc.target/riscv/cmo-zicbop-1.c: Remove references to __builtin_riscv_zicbop_cbo_prefetchi. * gcc.target/riscv/cmo-zicbop-2.c: Ditto with minor tidying. --- gcc/config/riscv/riscv-cmo.def | 4 ---- gcc/config/riscv/riscv.md | 9 --------- gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c | 6 ------ gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c | 8 +------- 4 files changed, 1 insertion(+), 26 deletions(-) diff --git a/gcc/config/riscv/riscv-cmo.def b/gcc/config/riscv/riscv-cmo.def index 017370d1d0e3..dbd5d2f0d9eb 100644 --- a/gcc/config/riscv/riscv-cmo.def +++ b/gcc/config/riscv/riscv-cmo.def @@ -12,10 +12,6 @@ RISCV_BUILTIN (inval_di, "zicbom_cbo_inval", RISCV_BUILTIN_DIRECT_NO_TARGET, RIS RISCV_BUILTIN (zero_si, "zicboz_cbo_zero", RISCV_BUILTIN_DIRECT_NO_TARGET, RISCV_VOID_FTYPE_VOID_PTR, zero32), RISCV_BUILTIN (zero_di, "zicboz_cbo_zero", RISCV_BUILTIN_DIRECT_NO_TARGET, RISCV_VOID_FTYPE_VOID_PTR, zero64), -// zicbop -RISCV_BUILTIN (prefetchi_si, "zicbop_cbo_prefetchi", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI, prefetch32), -RISCV_BUILTIN (prefetchi_di, "zicbop_cbo_prefetchi", RISCV_BUILTIN_DIRECT, RISCV_UDI_FTYPE_UDI, prefetch64), - // zbkc or zbc RISCV_BUILTIN (clmul_si, "clmul", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI_USI, clmul_zbkc32_or_zbc32), RISCV_BUILTIN (clmul_di, "clmul", RISCV_BUILTIN_DIRECT, RISCV_UDI_FTYPE_UDI_UDI, clmul_zbkc64_or_zbc64), diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 23d91331290b..4b445cb8be9c 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -118,7 +118,6 @@ UNSPECV_FLUSH UNSPECV_INVAL UNSPECV_ZERO - UNSPECV_PREI ;; Zihintpause unspec UNSPECV_PAUSE @@ -3493,14 +3492,6 @@ } [(set_attr "type" "cbo")]) -(define_insn "riscv_prefetchi_" - [(unspec_volatile:X [(match_operand:X 0 "address_operand" "r") - (match_operand:X 1 "imm5_operand" "i")] - UNSPECV_PREI)] - "TARGET_ZICBOP" - "prefetch.i\t%a0" - [(set_attr "type" "cbo")]) - (define_expand "extv" [(set (match_operand:GPR 0 "register_operand" "=r") (sign_extract:GPR (match_operand:GPR 1 "register_operand" "r") diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c index c5d78c1763d3..54b764fb7452 100644 --- a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c +++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c @@ -13,11 +13,5 @@ void foo (char *p) __builtin_prefetch (p, 1, 3); } -int foo1() -{ - return __builtin_riscv_zicbop_cbo_prefetchi(1); -} - -/* { dg-final { scan-assembler-times "prefetch.i" 1 } } */ /* { dg-final { scan-assembler-times "prefetch.r" 4 } } */ /* { dg-final { scan-assembler-times "prefetch.w" 4 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c index 6576365b39ca..917adc8f2008 100644 --- a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c +++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c @@ -13,11 +13,5 @@ void foo (char *p) __builtin_prefetch (p, 1, 3); } -int foo1() -{ - return __builtin_riscv_zicbop_cbo_prefetchi(1); -} - -/* { dg-final { scan-assembler-times "prefetch.i" 1 } } */ /* { dg-final { scan-assembler-times "prefetch.r" 4 } } */ -/* { dg-final { scan-assembler-times "prefetch.w" 4 } } */ +/* { dg-final { scan-assembler-times "prefetch.w" 4 } } */ From patchwork Mon Oct 23 07:22:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 156697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1127831vqx; Mon, 23 Oct 2023 00:25:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmG41s1BAvg0h5pWgrJZnBE8HHsfocXrJ9hcu8Pdv374JYTQzpUzxvepVx55cTQNo4e8dL X-Received: by 2002:a05:6214:76c:b0:66c:fd11:14dd with SMTP id f12-20020a056214076c00b0066cfd1114ddmr11221133qvz.29.1698045904107; Mon, 23 Oct 2023 00:25:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698045904; cv=pass; d=google.com; s=arc-20160816; b=ejDhxieFtnqOsds0Dl052vdh0Uf96Q/16y/fK9GLXVB2C03ryILcDCTgnd6r71g6r2 4oPhqLJFpu4RnJGqIk3i3fT4M65/6B/k/DC14EtykPhAd25UBEKGa3iU1Y9ACuOeqHtn PHGZEHgZ4FAFVoyxdSgojsLDnHrNg/VMWbM6bM5zpMg8zEhR3De+PpQX+Ui/RCYySmEt /srLETYr5t+6OUcz9QUbg2SSFKq6np1yW15skAza+4pGY7+gvE6chJp9tN4daamrEzPf 925PdH6BSJXL2eS2Yqg8XdxmLnfYIwfNBC5Ls/GMx4ml4f9PHae20JOTdA3/2YSH5ENR aesQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=baZMWkKRMJpeNY03YCW/twmY2XfmpZXdY8XXe8UKWZE=; fh=HKgiOHUFLyfVG2npWMLYE8/3Ecp4EiEdadhQOzpm3aI=; b=aoYXxaQ4P+ebIDkeV+l8wxy+OQSlpsB0wFfc6Hdivv2egvikChG4Hcfz8aceY5E7Ov 4RE1rYHZYqULXJTJEtkf+rQTEyEZPpm29xOggBTW9ThPOK8DKtYDbzRonup06139J9O8 HWp5QkUgFxtQ3/E2nJK8MmDyIydrAWzKBkKNemtXuOKurANMAuF5z9pZQ06kMjnIWoei DqOMMtMStp+24ZY4zAsOVCii1VpD4gG5MB4Y6iGYNog51nYEVLyXpgc38Aje2S1FhoUf EOQY2IRMTec9D3KIvEoRBV5pc6RV28vSIAV+mg0A6kO4uvQfe6Tf/92rTdFLvye5cvOD stBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=FjhUB2rE; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id om29-20020a0562143d9d00b0065b31ba68acsi5407785qvb.339.2023.10.23.00.25.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 00:25:04 -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; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=FjhUB2rE; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABE983875457 for ; Mon, 23 Oct 2023 07:24:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id C228B385E020 for ; Mon, 23 Oct 2023 07:24:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C228B385E020 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C228B385E020 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=153.120.152.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045865; cv=none; b=o47AGsNqv24M7GAddub1gQeBlgTrPbSuKrXv+2HNIOWul+RvrqZPsquAEj3FWNkgDBYZXGk2i3zK/OBtBUgpbdkrAR5Wqj5t/8BqrBJ8/YCfJy1NLictJLth2whQgrAwfbFQoXb1FUPUKy8j7/puSa34id8pmTYBomk7r7o9rIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045865; c=relaxed/simple; bh=FoFthWH66TuicDgVWRSVQzgwSIoneQLcV8pL1ymhZl4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=cpGeVLMdVpxPnzN+2XTWUo9TFxinZ1pkIlA5ytARaO+BxkmdwHzKeQzZjyYKtgDrVZDNDo9PefIC5RIMuRxkLdli+3ncffu43bD7QIIzC/kpO7z3WbXXr0fVHpFxxGPa4gtNG1XX9JLTFszJjWY/6Gs8G2KUQHvX8uW0Gqs9PM4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id C79DF300089; Mon, 23 Oct 2023 07:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1698045862; bh=baZMWkKRMJpeNY03YCW/twmY2XfmpZXdY8XXe8UKWZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=FjhUB2rE7OE5pgyI61ngIlJSwxOzcjppYBT/rA4AmS29O2RcWcnOjwy2RlCmunp7K 90EFpahyPsxhYlCP6Sn0Y/sSEnikOWSaTfdBtiR/AWER+lT5+TYK2vee6pFe/oJyMo BXlaJ2dUMsbQT85rXUMzjYQCoqV+L6qOu3S+19d0= From: Tsukasa OI To: Tsukasa OI , Kito Cheng , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] RISC-V: Add not broken RW prefetch RTL instructions without offsets Date: Mon, 23 Oct 2023 07:22:54 +0000 Message-ID: <671a5e3bc2ca33b9050c54d2f53dd0580339b858.1698045769.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_MANYTO, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780530181813618974 X-GMAIL-MSGID: 1780530181813618974 From: Tsukasa OI To prepare adding new not broken prefetch built-in functions and fixing an ICE in __builtin_prefetch, this commit adds two new instructions, each corresponding a 'Zicbop' prefetch hint instruction, but with no specifiable offset field for simplicity. This commit also excludes new instruction corresponding "prefetch.i" because it is not needed to fix an ICE (so new instruction corresponding "prefetch.i" is going to be a separate commit). gcc/ChangeLog: * config/riscv/riscv.md (unspecv) Add UNSPECV_PREFETCH_[RW]. (riscv_prefetch_w_, riscv_prefetch_w_): New. --- gcc/config/riscv/riscv.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 4b445cb8be9c..e67a6d1f1b81 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -118,6 +118,8 @@ UNSPECV_FLUSH UNSPECV_INVAL UNSPECV_ZERO + UNSPECV_PREFETCH_R + UNSPECV_PREFETCH_W ;; Zihintpause unspec UNSPECV_PAUSE @@ -3492,6 +3494,20 @@ } [(set_attr "type" "cbo")]) +(define_insn "riscv_prefetch_r_" + [(unspec_volatile:X [(match_operand:X 0 "register_operand" "r")] + UNSPECV_PREFETCH_R)] + "TARGET_ZICBOP" + "prefetch.r\t0(%0)" + [(set_attr "type" "cbo")]) + +(define_insn "riscv_prefetch_w_" + [(unspec_volatile:X [(match_operand:X 0 "register_operand" "r")] + UNSPECV_PREFETCH_W)] + "TARGET_ZICBOP" + "prefetch.w\t0(%0)" + [(set_attr "type" "cbo")]) + (define_expand "extv" [(set (match_operand:GPR 0 "register_operand" "=r") (sign_extract:GPR (match_operand:GPR 1 "register_operand" "r") From patchwork Mon Oct 23 07:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 156698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1127887vqx; Mon, 23 Oct 2023 00:25:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwVNryAl56xfzIE4XFEvokau/PBw5Qu3Xiy9n/f6yTUb2qpc3+kOh5IM7wjNfb1LOxFQRq X-Received: by 2002:ad4:5f87:0:b0:66d:1eb6:96c9 with SMTP id jp7-20020ad45f87000000b0066d1eb696c9mr12775470qvb.60.1698045913660; Mon, 23 Oct 2023 00:25:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698045913; cv=pass; d=google.com; s=arc-20160816; b=b+h0I76dpWhRS7VIflPVSojt6Wk0smpjyL2DYaUhE+xy5jym+GICsBPrKzoXwIWZOs iIEHsoGmx840kxwHueGqWKBLjRdP8T7MqaCwveXZCJqBj7MlRpOS58OGNKb0tbkTTCvk VmYPkxupzXqVBbm+OYzAq3LJS8E5qOu2N9QCWZjFezcGu4I1KXXlHyRpeNvwTGvFDz4c yK5crwnRe7+RxDISY2kgzo7PWs3ZLt/Em/Web0Nma+GFQXN27+01cZ80+SETGk7CHXRo HaoY1Y322/hVlj4Pq1v05xH+AuTkAQ04qanFtIyk2HKTBiCb26gplnucVUxym4AGlqJ+ 5G3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=wXpO+y3EjFiyaydSnnRbwAJYTwxX7PmnveCKXJbYPU0=; fh=HKgiOHUFLyfVG2npWMLYE8/3Ecp4EiEdadhQOzpm3aI=; b=M5ilUYdkHtivmve0KWjpGZ1Te6O+53+sUm/jZWfTCeJSrCFw7N3w40h39DmJfB0I6t JGFn90TYMEDIKhZc/mriDIPYIcLjXVtyJbEM6oaGK17d5kWSTWL41WZER8Stz0YGDHQJ gCesqO2ZuBFliEqsjkekxPz+GG1yX0l2uQL0wsEop1v7HpMSQ/Gz1RqItmoeZhI65/Xz 03S3PblmmZVWIw1vShSxMtKLsVi8ViCdG+QhioX7TJ0+tuVnNCrDe1mNd3qwwrvRimSg BItRmkrczJx0VNvZDi6XQHaQtPDhOHRiB1LBuU7FQzzNjV5svPElxUdhiM0HiYgM4eov oIfA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=rWEIOCZj; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ks30-20020a056214311e00b0066d0a6ee60asi5267202qvb.226.2023.10.23.00.25.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 00:25:13 -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; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=rWEIOCZj; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B92093853508 for ; Mon, 23 Oct 2023 07:25:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id A3E6F3861918 for ; Mon, 23 Oct 2023 07:24:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3E6F3861918 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A3E6F3861918 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2401:2500:203:30b:4000:6bfe:4757:0 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045876; cv=none; b=pG8GQEb1x6NZ+IsRy8y04u2PIA0lEKORBJfKk7OawSUla2PimbdQb1HBofS1Xj9lC1rhc8n+QTMNtDH6yzY3ZoPRbU6TmwSYBWQxkQhfgA3hl+a8kvBYLybIPQVNP6nO26bJ/NGpIk28eh5WErCWaYKt/8gFCV1eDamQENkFMg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698045876; c=relaxed/simple; bh=XZVf9qy/8MX4/4GW09e02M0gVhNIo/qJAPoiUXWhoP0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=BmGUPCAAsoqp7n8x51+gqnyluXPxhskMZr7XOwm2gOzNFqObwXzgmvibOkeaKfMRkSh4f4lef+WmfJtnFgOmsuyz5grXvzv39PFY5QG7uwKfJUiEg1SrF4P0OedXQ7O9hvUQz6nQasN/INrmP5NO+uQCFGb1rC8MK/VEQCg4KG4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 92791300089; Mon, 23 Oct 2023 07:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1698045872; bh=wXpO+y3EjFiyaydSnnRbwAJYTwxX7PmnveCKXJbYPU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=rWEIOCZj60d4ZIN96TVGkt2F3gBHMvXZGUYPQp+0BCtDuz9xp6Mz8K9r2cJRU5Pmo WPEpiqucVD7hfy4nexUMw/bHnqbBUnMxhnNEqHYSyWR2XnknK5pHKSq/najg2u8eVV +iBEn595QGUeshPV+GWxwOUC0ezU8wTIG/v+ehTo= From: Tsukasa OI To: Tsukasa OI , Kito Cheng , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 4/4] RISC-V: Fix ICE by expansion and register coercion Date: Mon, 23 Oct 2023 07:22:55 +0000 Message-ID: In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, KAM_MANYTO, KAM_SHORT, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780530192115243890 X-GMAIL-MSGID: 1780530192115243890 From: Tsukasa OI A "prefetch" instruction on RISC-V GCC emits a machine hint instruction directly when the 'Zicbop' extension is enabled but it could cause an ICE when the address argument of __builtin_prefetch is an integral constant (such like 0 [NULL] or some other [but possibly not all] fixed addresses). This is caused by the fact that the "r" constraint is not actually checked and something other than a register can be the first argument of the "prefetch" RTL instruction. It fixes the problem by changing "prefetch" from a native instruction to an expansion and coercing the address to a register there. gcc/ChangeLog: * config/riscv/riscv.md (prefetch): Expand to a native prefetch instruction instead of emitting a machine instruction directly. Coerce the address argument into a register. gcc/testsuite/ChangeLog: * gcc.target/riscv/cmo-zicbop-by-common-ice-1.c: New ICE test. * gcc.target/riscv/cmo-zicbop-by-common-ice-2.c: Ditto. --- gcc/config/riscv/riscv.md | 43 ++++++++++++------- .../riscv/cmo-zicbop-by-common-ice-1.c | 13 ++++++ .../riscv/cmo-zicbop-by-common-ice-2.c | 7 +++ 3 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-2.c diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index e67a6d1f1b81..bf232345b1ab 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -3479,21 +3479,6 @@ [(set_attr "type" "cbo")] ) -(define_insn "prefetch" - [(prefetch (match_operand 0 "address_operand" "r") - (match_operand 1 "imm5_operand" "i") - (match_operand 2 "const_int_operand" "n"))] - "TARGET_ZICBOP" -{ - switch (INTVAL (operands[1])) - { - case 0: return "prefetch.r\t%a0"; - case 1: return "prefetch.w\t%a0"; - default: gcc_unreachable (); - } -} - [(set_attr "type" "cbo")]) - (define_insn "riscv_prefetch_r_" [(unspec_volatile:X [(match_operand:X 0 "register_operand" "r")] UNSPECV_PREFETCH_R)] @@ -3508,6 +3493,34 @@ "prefetch.w\t0(%0)" [(set_attr "type" "cbo")]) +(define_expand "prefetch" + [(prefetch (match_operand 0 "address_operand" "") + (match_operand 1 "const_int_operand" "") + (match_operand 2 "const_int_operand" ""))] + "TARGET_ZICBOP" +{ + operands[0] = force_reg (Pmode, operands[0]); + switch (INTVAL (operands[1])) + { + case 0: + if (TARGET_64BIT) + emit_insn (gen_riscv_prefetch_r_di (operands[0])); + else + emit_insn (gen_riscv_prefetch_r_si (operands[0])); + break; + case 1: + if (TARGET_64BIT) + emit_insn (gen_riscv_prefetch_w_di (operands[0])); + else + emit_insn (gen_riscv_prefetch_w_si (operands[0])); + break; + default: + gcc_unreachable (); + } + DONE; +} + [(set_attr "type" "cbo")]) + (define_expand "extv" [(set (match_operand:GPR 0 "register_operand" "=r") (sign_extract:GPR (match_operand:GPR 1 "register_operand" "r") diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-1.c b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-1.c new file mode 100644 index 000000000000..47e83f29cc5c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32i_zicbop -mabi=ilp32" } */ + +void foo (void) +{ + /* Second argument defaults to zero (read). */ + __builtin_prefetch (0); + __builtin_prefetch (0, 0); + __builtin_prefetch (0, 1); +} + +/* { dg-final { scan-assembler-times "prefetch\\.r" 2 } } */ +/* { dg-final { scan-assembler-times "prefetch\\.w" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-2.c b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-2.c new file mode 100644 index 000000000000..a245b8163c1f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-by-common-ice-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64i_zicbop -mabi=lp64" } */ + +#include "cmo-zicbop-by-common-ice-1.c" + +/* { dg-final { scan-assembler-times "prefetch\\.r" 2 } } */ +/* { dg-final { scan-assembler-times "prefetch\\.w" 1 } } */