[PATCH v3 0/5] riscv: Use __riscv_has_extension_{likely,unlikely}

Vivian Wang wangruikang at iscas.ac.cn
Fri Oct 10 16:38:30 PDT 2025


On 10/11/25 07:35, Vivian Wang wrote:

> There are about a dozen uses of asm goto in arch/riscv just to select
> between two code paths with the alternative mechanism. Convert them to
> the existing helpers __riscv_has_extension_{likely,unlikely}.
>
> In each case, I have preserved the existing code's choice of asm goto
> pattern while picking between "likely" and "unlikely", namely:
>
>   ALTERNATIVE("j %l[no]", "nop", ...)   -> "likely"
>   ALTERNATIVE("nop", "j %l[yes]", ...)  -> "unlikely"
>
> Since the helpers are just implementations of these patterns, the
> performance should be the same as before.
>
> These patches are also available at:
>
> https://github.com/dramforever/linux/tree/riscv/altn-helper/v2
I made a mistake while writing the cover letter, the correct link is:

https://github.com/dramforever/linux/tree/riscv/altn-helper/v3

Vivian "dramforever" Wang




More information about the linux-riscv mailing list