-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
backend:X86good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributemissed-optimization
Description
https://zig.godbolt.org/z/v3rqr86P1
We attempt to vectorize scalar fp->int->fp round trips to avoid transfer from the FPU to the GPRs and back again:
define double @scvtf64_i32(double %a0) {
%ii = fptosi double %a0 to i32
%ff = sitofp i32 %ii to double
ret double %ff
}
define float @scvtf32_i32(float %a0) {
%ii = fptosi float %a0 to i32
%ff = sitofp i32 %ii to float
ret float %ff
}
scvtf64_i32: # @scvtf64_i32
vcvttpd2dq %xmm0, %xmm0
vcvtdq2pd %xmm0, %xmm0
retq
scvtf32_i32: # @scvtf32_i32
vcvttps2dq %xmm0, %xmm0
vcvtdq2ps %xmm0, %xmm0
retq
This is currently only performed for f64/32 <-> i32 legal SSE2+ FP_TO_SINT/SINT_TO_FP conversions.
AVX512VL could handle this for FP_TO_UINT/UINT_TO_FP conversions as well (AVX512F if we widen to 512-bits instead of 128-bit).
AV512DQ+AVX512VL could handle this for f64/32 <-> i64 SINT and UINT conversions as well.
This will require adjusting lowerFPToIntToFP to recognize FP_TO_UINT/UINT_TO_FP patterns on AVX512VL targets and i64 scalars on AV512DQ+AVX512VL targets, along with any additional test coverage that we don't already have.
Metadata
Metadata
Assignees
Labels
backend:X86good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributemissed-optimization