[X86] bf16 to float conversion fails to stay on FPU
https://godbolt.org/z/qTasEq77v
define float @src(bfloat %a0) {
%res = fpext bfloat %a0 to float
ret float %res
}
src: # @src
pextrw $0, %xmm0, %eax
shll $16, %eax
movd %eax, %xmm0
retq
This could be handled as:
src: # @src
pmovzxwd %xmm0, %xmm0 ; UNPCKLWD pre-SSE41
pslld $16, %xmm0
retq
Hopefully we can handle this generically instead of handling it in explicit fpext lowering
@llvm/issue-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
define float @<!-- -->src(bfloat %a0) {
%res = fpext bfloat %a0 to float
ret float %res
}
src: # @<!-- -->src
pextrw $0, %xmm0, %eax
shll $16, %eax
movd %eax, %xmm0
retq
This could be handled as:
src: # @<!-- -->src
pmovzxwd %xmm0, %xmm0 ; UNPCKLWD pre-SSE41
pslld $16, %xmm0
retq
Hopefully we can handle this generically instead of handling it in explicit fpext lowering
Hi Simon (@RKSimon), I would like to take a crack at this. Would you help assign it to me please? Thanks!
@ningxinr, there were some bugs with bfloat16 on x86 that were reported at https://github.com/llvm/llvm-project/issues/151692 and https://github.com/llvm/llvm-project/issues/134222, along with a draft pull request at https://github.com/llvm/llvm-project/pull/134859 to improve bfloat16 code generation on X86.