Add narrowScalarFor action and
narrow scalar for typeIndex==0 for G_FPTOSI/G_FPTOUI.
Legalize using narrowScalarFor as s16->s32 G_FPTOSI/G_FPTOUI
followed by s32->s64 G_SEXT/G_ZEXT.
Details
Diff Detail
Event Timeline
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fptosi.mir | ||
---|---|---|
598–633 | This expansion is huge! How about implementing it as: fpext from f16 to f32, then fptosi/fptoui from f32 to i32 (you know this will be in range because the range of f16 is only about +/-65536), then sext/zext from i32 to i64? |
This might be narrowScalar on TypeIndex==0 but it requires that s16 is at TypeIndex==1 thus I used custom legalize.
The generated code looks much better, thanks. The implementation looks OK to me too, but perhaps wait to see if @arsenm has comments?
You can do
.narrowScalarIf(all(typeIs(0, S64), typeIs(1, S16)), changeTo(0, S32))
but we should have a narrowFor like the other actions
Also it might be worth fixing this in the DAG. It ends up with the huge expansion now
Missing space after ,