Issue 241707
Summary [X86][AVX512] improve scalar llvm.fptoui.sat avx512dq codegen
Labels good first issue, backend:X86, missed-optimization, floating-point
Assignees
Reporter Andarwinux
    https://godbolt.org/z/TWT3cbYEo
```llvm
define i32 @test_unsigned_i32_f32(float %f) nounwind {
 %x = call i32 @llvm.fptoui.sat.i32.f32(float %f)
  ret i32 %x
}
```
-O3 -mcpu=tigerlake
```asm
.LCPI0_0:
        .long   0x4f7fffff # float 4.29496704E+9
test_unsigned_i32_f32:                  # @test_unsigned_i32_f32
        vcvttss2si      rax, xmm0
        xor ecx, ecx
        vxorps  xmm1, xmm1, xmm1
        vucomiss        xmm0, xmm1
        cmovae  ecx, eax
        vucomiss        xmm0, dword ptr [rip + .LCPI0_0]
        mov     eax, -1
        cmovbe  eax, ecx
 ret
```
should be
```c++
#include <immintrin.h>
unsigned int foo(__m128 x){
    return _mm_maskz_cvttps_epu32(~_mm_fpclass_ss_mask(x,0xD7),x)[0];
}
```
```asm
foo(float vector[4]):
        vfpclassss      k0, xmm0, 215
        knotw   k1, k0
 vcvttps2udq     xmm0 {k1} {z}, xmm0
        vmovd   eax, xmm0
 ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to