* [PATCH v2] riscv: lib: relax assembly constraints in hweight
@ 2024-05-27 9:24 Qingfang Deng
2024-05-27 10:23 ` Wang, Xiao W
2024-07-16 14:40 ` patchwork-bot+linux-riscv
0 siblings, 2 replies; 3+ messages in thread
From: Qingfang Deng @ 2024-05-27 9:24 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv,
linux-kernel
Cc: Xiao Wang, Qingfang Deng
From: Qingfang Deng <qingfang.deng@siflower.com.cn>
rd and rs don't have to be the same. In some cases where rs needs to be
saved for later usage, this will save us some mv instructions.
Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
---
v2: updated title as suggested by Xiao.
arch/riscv/include/asm/arch_hweight.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/include/asm/arch_hweight.h b/arch/riscv/include/asm/arch_hweight.h
index 85b2c443823e..613769b9cdc9 100644
--- a/arch/riscv/include/asm/arch_hweight.h
+++ b/arch/riscv/include/asm/arch_hweight.h
@@ -26,9 +26,9 @@ static __always_inline unsigned int __arch_hweight32(unsigned int w)
asm (".option push\n"
".option arch,+zbb\n"
- CPOPW "%0, %0\n"
+ CPOPW "%0, %1\n"
".option pop\n"
- : "+r" (w) : :);
+ : "=r" (w) : "r" (w) :);
return w;
@@ -57,9 +57,9 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
asm (".option push\n"
".option arch,+zbb\n"
- "cpop %0, %0\n"
+ "cpop %0, %1\n"
".option pop\n"
- : "+r" (w) : :);
+ : "=r" (w) : "r" (w) :);
return w;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v2] riscv: lib: relax assembly constraints in hweight
2024-05-27 9:24 [PATCH v2] riscv: lib: relax assembly constraints in hweight Qingfang Deng
@ 2024-05-27 10:23 ` Wang, Xiao W
2024-07-16 14:40 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: Wang, Xiao W @ 2024-05-27 10:23 UTC (permalink / raw)
To: Qingfang Deng, Paul Walmsley, Palmer Dabbelt, Albert Ou,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Qingfang Deng
> -----Original Message-----
> From: Qingfang Deng <dqfext@gmail.com>
> Sent: Monday, May 27, 2024 5:24 PM
> To: Paul Walmsley <paul.walmsley@sifive.com>; Palmer Dabbelt
> <palmer@dabbelt.com>; Albert Ou <aou@eecs.berkeley.edu>; linux-
> riscv@lists.infradead.org; linux-kernel@vger.kernel.org
> Cc: Wang, Xiao W <xiao.w.wang@intel.com>; Qingfang Deng
> <qingfang.deng@siflower.com.cn>
> Subject: [PATCH v2] riscv: lib: relax assembly constraints in hweight
>
> From: Qingfang Deng <qingfang.deng@siflower.com.cn>
>
> rd and rs don't have to be the same. In some cases where rs needs to be
> saved for later usage, this will save us some mv instructions.
>
> Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
> ---
> v2: updated title as suggested by Xiao.
>
> arch/riscv/include/asm/arch_hweight.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/include/asm/arch_hweight.h
> b/arch/riscv/include/asm/arch_hweight.h
> index 85b2c443823e..613769b9cdc9 100644
> --- a/arch/riscv/include/asm/arch_hweight.h
> +++ b/arch/riscv/include/asm/arch_hweight.h
> @@ -26,9 +26,9 @@ static __always_inline unsigned int
> __arch_hweight32(unsigned int w)
>
> asm (".option push\n"
> ".option arch,+zbb\n"
> - CPOPW "%0, %0\n"
> + CPOPW "%0, %1\n"
> ".option pop\n"
> - : "+r" (w) : :);
> + : "=r" (w) : "r" (w) :);
>
> return w;
>
> @@ -57,9 +57,9 @@ static __always_inline unsigned long
> __arch_hweight64(__u64 w)
>
> asm (".option push\n"
> ".option arch,+zbb\n"
> - "cpop %0, %0\n"
> + "cpop %0, %1\n"
> ".option pop\n"
> - : "+r" (w) : :);
> + : "=r" (w) : "r" (w) :);
>
> return w;
>
> --
> 2.34.1
Reviewed-by: Xiao Wang <xiao.w.wang@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] riscv: lib: relax assembly constraints in hweight
2024-05-27 9:24 [PATCH v2] riscv: lib: relax assembly constraints in hweight Qingfang Deng
2024-05-27 10:23 ` Wang, Xiao W
@ 2024-07-16 14:40 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-07-16 14:40 UTC (permalink / raw)
To: Qingfang Deng
Cc: linux-riscv, paul.walmsley, palmer, aou, linux-kernel,
xiao.w.wang, qingfang.deng
Hello:
This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:
On Mon, 27 May 2024 17:24:04 +0800 you wrote:
> From: Qingfang Deng <qingfang.deng@siflower.com.cn>
>
> rd and rs don't have to be the same. In some cases where rs needs to be
> saved for later usage, this will save us some mv instructions.
>
> Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
>
> [...]
Here is the summary with links:
- [v2] riscv: lib: relax assembly constraints in hweight
https://git.kernel.org/riscv/c/93b63f68d00a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-16 14:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27 9:24 [PATCH v2] riscv: lib: relax assembly constraints in hweight Qingfang Deng
2024-05-27 10:23 ` Wang, Xiao W
2024-07-16 14:40 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox