Add widenScalar for TypeIdx == 0 for G_SITOFP/G_UITOFP.
Legailize, using widenScalar, as s64->s32 G_SITOFP/G_UITOFP
followed by s32->s16 G_FPTRUNC.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Legailize as s64->s32 G_SITOFP/G_UITOFP followed by s32->s16 G_FPTRUNC.
It seems like this would give the wrong result in some cases because of the double rounding. What does SelectionDAG do?
It looks like it does the same thing. AMDGPU and AArch64 both seem to do the same thing in custom lowering. I think since the source is an integer, there really isn't a whole lot of opportunity for rounding to do much.
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | ||
---|---|---|
647 | Could you move this to widenScalar for TypeIdx == 0 in LegalizerHelper instead of making this custom? | |
1828 | Missing spaces around == |
The range of a half is only about +/- 65536, and any integer in that range will convert to float exactly without rounding, so there is no double rounding problem.
LGTM
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-uitofp.mir | ||
---|---|---|
484 | Can also use v2s64 to v2s16 |
Could you move this to widenScalar for TypeIdx == 0 in LegalizerHelper instead of making this custom?