From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by sourceware.org (Postfix) with ESMTPS id 33282385EC57 for ; Sat, 1 Jun 2024 04:34:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33282385EC57 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33282385EC57 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::82b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717216483; cv=none; b=nT/5O58qW5ZGIsC0gO/GaZUfQ/fvXBM8NQSO9ngc8Q7I+hc7A6ERNutsKgGSalZVZvXfqT9uVTbyjPpCoaOtaSqoM8vPHEGKG7KgFn4RhP0vA9PeYir+Rt9fvvZ5zHzqaYflt1U8esoi6BGFKUHvPSX8lMlCw8+InPXjvoIWf8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717216483; c=relaxed/simple; bh=8BGEgaYJSAIbCelPUnAE1Z7oC7mOTMvoLVB7gqAgwuA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Lkn7IbrJiXaBZs4t9I2f1GuJPr0wEXu5K+rzuKhPUZmiiCCLTbA6UBgwBq9e85WEPYzU6Fto4eGnuEWzJQBgVN6el00Rrt+Gxctgl5Rptt3TSnHC+a5ISDu25Zbgz69rvJdcjgQNZlV+a62L1gm8aoV/nf7sB/pV2l3EHsOIbtg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-43fc100549cso14265331cf.0 for ; Fri, 31 May 2024 21:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717216480; x=1717821280; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VHMV3i0ZwT09vEIeNJnYGvipi5qU5xld46s4d8swlNA=; b=Lj4s+vmxo5KefOylzLNy3h6KWdRx8K4V27Oul9qGjRTxQHbupQOgCelMv9SOaqK2aK F3c2rZ6aU3D56VUkQXR8GPo3dSHw2f1CNv9FGC+W2s5L79RyPpZG4KzPcT3nL0w3qSYO ec+CbAQ6IBHEFQlfsLxNjua4VD5egpVPYUFgufN4Vpooa0GfTEbWrTwYfSxmfkg8rDqd j4Ds8aKzPxX6D6CzdRltsz1UBU4RaOT+VdpiB14DB4EuAlR0lv90GtWDmia/W3yiXa48 uTjbFXy/qsepZDOZhyj99NRMWGzIcw1HgvDTgB7idI9GJiSdJomaculLhgZgnmeXraFw DmaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717216480; x=1717821280; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VHMV3i0ZwT09vEIeNJnYGvipi5qU5xld46s4d8swlNA=; b=XHMdAHOq3Bg8dq4pUZmtPQfDmOiz4Nb2AK1zhAWlQ8/BJufcryGVtRLTmi1OJ+ks8C Wkb1bjKCHS0gGp0r5QktP37v0LYb6pNjZXMxUGalQj6v0JqPqoheljGQckBzQ2MoZ8uq aZaAERtCl0yxDYwaK5/vM9zuoMZC1QypIsv+XbVv2ITu/8ZyTzDX9BOQt1GSbIICIgb3 2IWofkqLapDcO5CtfU7c8ZX/QJcPnR/K4ydRdgyd/6hOujxp7d4vOcF4eh85MWIb1npH lPd9Y2HaAi+/b5Gi0/OBHPOXIh9AG0AeFyajmmx6z0G72NFWR8dXJJ2rbKP7ttaez8Wd iPqg== X-Forwarded-Encrypted: i=1; AJvYcCUnv0LJgFVWuDCXrZSxqe+pcsvcOZ5Sd35tEfAW/oQNLlhvc0+BDWfNEKzCUnE6xrdT6Rke+odbFMB8ics1arfLc8kUU/aLVA== X-Gm-Message-State: AOJu0Yyu67Zr1ygfxcWoUMpTHt5PWKzFMeuwneBIL2SNFZ1CRDKJ/qNI HkuRHrhDsYJVjl9V4XaGyiVIP0sU9gCNuXO6CAWUd7t0i2B06cqi X-Google-Smtp-Source: AGHT+IG/R4OYd27ibw3g9u8FzI4U0WnrI8YXeiTxOd0ValQnJweD6FAUJaxzJmFwpsk9TqpbUN9ZhA== X-Received: by 2002:ac8:58d6:0:b0:43f:f19a:104d with SMTP id d75a77b69052e-43ff525ae6fmr47393011cf.40.1717216480423; Fri, 31 May 2024 21:34:40 -0700 (PDT) Received: from [192.168.3.58] ([216.181.162.155]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43ff246b00csm14785041cf.61.2024.05.31.21.34.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 May 2024 21:34:39 -0700 (PDT) Message-ID: <07edbdf3-bf9e-4fdf-9a2b-4a52ead8b495@gmail.com> Date: Fri, 31 May 2024 22:34:35 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PING] [PATCH] RISC-V: Add Zfbfmin extension Content-Language: en-US To: Xiao Zeng , gcc-patches@gcc.gnu.org Cc: research_trasio@irq.a4lg.com, kito.cheng@gmail.com, palmer@dabbelt.com, zhengyu@eswincomputing.com References: <20240530113827.23143-1-zengxiao@eswincomputing.com> From: Jeff Law In-Reply-To: <20240530113827.23143-1-zengxiao@eswincomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=no 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 5/30/24 5:38 AM, Xiao Zeng wrote: > 1 In the previous patch, the libcall for BF16 was implemented: > > > 2 Riscv provides Zfbfmin extension, which completes the "Scalar BF16 Converts": > > > 3 Implemented replacing libcall with Zfbfmin extension instruction. > > 4 Reused previous testcases in: > > > gcc/ChangeLog: > > * config/riscv/riscv.cc (riscv_output_move): Handle BFmode move > for zfbfmin. > * config/riscv/riscv.md (truncsfbf2): New pattern for BFmode. > (trunchfbf2): Dotto. > (truncdfbf2): Dotto. > (trunctfbf2): Dotto. > (extendbfsf2): Dotto. > (*movhf_hardfloat): Add BFmode. > (*mov_hardfloat): Dotto. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/zfbfmin-bf16_arithmetic.c: New test. > * gcc.target/riscv/zfbfmin-bf16_comparison.c: New test. > * gcc.target/riscv/zfbfmin-bf16_float_libcall_convert.c: New test. > * gcc.target/riscv/zfbfmin-bf16_integer_libcall_convert.c: New test. > --- > > + > +;; The conversion of HF/DF/TF to BF needs to be done with SF if there is a > +;; chance to generate at least one instruction, otherwise just using > +;; libfunc __trunc[h|d|t]fbf2. > +(define_expand "trunchfbf2" > + [(set (match_operand:BF 0 "register_operand" "=f") > + (float_truncate:BF > + (match_operand:HF 1 "register_operand" " f")))] > + "TARGET_ZFBFMIN" > + { > + convert_move (operands[0], > + convert_modes (SFmode, HFmode, operands[1], 0), 0); > + DONE; > + } > + [(set_attr "type" "fcvt") > + (set_attr "mode" "BF")]) I would suggest using a mode iterator to avoid explicit pattern duplication. Essentially a mode iterator allows you to specify that the pattern should be repeated over a series of modes. It looks like you've deine a conversion from HF, DF, TF. So you define an iterator that includes just those modes. You would use the mode iterator rather than BF, DF or TF in your pattern. That just fixes the mode in the pattern. You also need to have the name automagically adjust as well. Use in the name. so the name would be somethig like truncbf2. When you want to reference the mode in code you can do something like E_mode And that will map down to HFmode, BFmode, TFmode appropriately. I suspect you can do something similar for the extension patterns. In fact, it looks like you did this for the movehardfloat pattern. Jeff