Skip to content

Commit 93b63f6

Browse files
LGA1150palmer-dabbelt
authored andcommitted
riscv: lib: relax assembly constraints in hweight
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> Reviewed-by: Xiao Wang <xiao.w.wang@intel.com> Link: https://lore.kernel.org/r/20240527092405.134967-1-dqfext@gmail.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 6ad8735 commit 93b63f6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/riscv/include/asm/arch_hweight.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ static __always_inline unsigned int __arch_hweight32(unsigned int w)
2626

2727
asm (".option push\n"
2828
".option arch,+zbb\n"
29-
CPOPW "%0, %0\n"
29+
CPOPW "%0, %1\n"
3030
".option pop\n"
31-
: "+r" (w) : :);
31+
: "=r" (w) : "r" (w) :);
3232

3333
return w;
3434

@@ -57,9 +57,9 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
5757

5858
asm (".option push\n"
5959
".option arch,+zbb\n"
60-
"cpop %0, %0\n"
60+
"cpop %0, %1\n"
6161
".option pop\n"
62-
: "+r" (w) : :);
62+
: "=r" (w) : "r" (w) :);
6363

6464
return w;
6565

0 commit comments

Comments
 (0)