[llvm] [SelectionDAG] optimize sdiv with positive divisor and positive magic (PR #189287)
Takashi Idobe via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 06:15:01 PDT 2026
Takashiidobe wrote:
> Interesting. "main" could avoid using x9 with a different optimization:
>
> ```assembly
> sdiv3: // @sdiv3
> mov w8, #21846
> movk w8, #21845, lsl #16
> smull x8, w0, w8
> lsr x8, x8, #32
> add x0, x8, x8, lsr #31 # since x>>63 is x>>32>>31
> ret
> ```
Seems like good enough evidence to me to make this x86_64 only. I'll rewrite this diff and ask for reviews once i'm done.
I can write a follow up issue for the lsr fold you suggested too.
https://github.com/llvm/llvm-project/pull/189287
More information about the llvm-commits
mailing list