From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 749843858D28 for ; Tue, 29 Aug 2023 02:09:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 749843858D28 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 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id C0676300089; Tue, 29 Aug 2023 02:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1693274997; bh=Xc1dEPCr0/dL0oDvd7VYSH0B5FVT2fu+DEHTjNlH5AI=; h=Message-ID:Date:Mime-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=BaBKl+jLA9vVS7swRv5d/V5k4lqMpq+q2txzNazpNE6Rg/iGPtrqiffdSQe+4Iz6l GWP3Jh5KndKqORqrrsEd+Zgwq2bfNJy3Px7mQhZi0tuOmRnbiW/NGGOnIAaE+zXK4r PbzDuX/4iXg8B0o8+kp8ADlWvX1f/XECR076rMsU= Message-ID: Date: Tue, 29 Aug 2023 11:09:56 +0900 Mime-Version: 1.0 Subject: Re: [PATCH 1/1] RISC-V: Make "prefetch.i" built-in usable Content-Language: en-US To: Jeff Law , Kito Cheng , Palmer Dabbelt , Andrew Waterman , Jim Wilson Cc: gcc-patches@gcc.gnu.org References: <97c0d824fa5aeaee52a825da7f7a17ae8616c5ab.1691636916.git.research_trasio@irq.a4lg.com> <5b7219c9-76d6-574b-a7e4-2e0992a56198@gmail.com> From: Tsukasa OI In-Reply-To: <5b7219c9-76d6-574b-a7e4-2e0992a56198@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,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 List-Id: On 2023/08/29 6:20, Jeff Law wrote: > > > On 8/9/23 21:10, Tsukasa OI via Gcc-patches wrote: >> From: Tsukasa OI >> >> The "__builtin_riscv_zicbop_cbo_prefetchi" built-in function was terribly >> broken so that practically unusable.  It emitted "prefetch.i" but with no >> meaningful arguments. >> >> Though incompatible, this commit completely changes the function >> prototype >> of this built-in and makes it usable.  To minimize the functionality >> issues, >> it renames the built-in to "__builtin_riscv_zicbop_prefetch_i". >> >> gcc/ChangeLog: >> >>     * config/riscv/riscv-cmo.def: Fix function prototype. >>     * config/riscv/riscv.md (riscv_prefetchi_): Fix instruction >>     prototype.  Remove possible prefectch type argument >>     * doc/extend.texi: Document __builtin_riscv_zicbop_prefetch_i. >> >> gcc/testsuite/ChangeLog: >> >>     * gcc.target/riscv/cmo-zicbop-1.c: Reflect new built-in prototype. >>     * gcc.target/riscv/cmo-zicbop-2.c: Likewise. >> diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md >> index 688fd697255b..5658c7b7e113 100644 >> --- a/gcc/config/riscv/riscv.md >> +++ b/gcc/config/riscv/riscv.md >> @@ -3273,9 +3273,8 @@ >>   }) >>     (define_insn "riscv_prefetchi_" >> -  [(unspec_volatile:X [(match_operand:X 0 "address_operand" "r") >> -              (match_operand:X 1 "imm5_operand" "i")] >> -              UNSPECV_PREI)] >> +  [(unspec_volatile:X [(match_operand:X 0 "register_operand" "r")] >> +    UNSPECV_PREI)] >>     "TARGET_ZICBOP" >>     "prefetch.i\t%a0" >>   ) > What I would suggest is making a new predicate that accepts either a > register or a register+offset where the offset fits in a signed 12 bit > immediate.  Use that for operand 0's predicate and I think this will > "just work" and cover all the cases supported by the prefetch.i > instruction. > > Jeff > Seems reasonable. If we have to break the compatibility anyway, adding an offset argument is not a bad idea (though I think they will use inline assembly if a non-zero offset is required). I will try to add *optional* offset argument (with default value 0) like __builtin_speculation_safe_value built-in function in the next version. Thanks, Tsukasa