[llvm] [RISCV][GlobalISel] Fix fptosi/fptoui from half to i64 on RV32 (PR #222316)

Kane Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 20:03:51 PDT 2026


ReVe1uv wrote:

> Can you not just extend the result of fcvt.w.h? The magnitude of a half is at most 65504.

Thanks! I originally mirrored SelectionDAG, which calls `__fixhfdi/__fixunshfdi` here, but extending the `fcvt.w[u].h` result is clearly better. I've switched to `narrowScalarFor({{s64, s16}}, changeTo(0, s32)),` which now emits `fcvt.w.h + srai` (and `fcvt.wu.h` + `li` for unsigned). The libcalls remain for the no-Zfh case, where no half conversion instructions are available.

https://github.com/llvm/llvm-project/pull/222316


More information about the llvm-commits mailing list