Skip to content

Commit

Permalink
riscv: lib: relax assembly constraints in hweight
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Qingfang Deng authored and Palmer Dabbelt committed Jul 15, 2024
1 parent 6ad8735 commit 93b63f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions arch/riscv/include/asm/arch_hweight.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 93b63f6

Please sign in to comment.