llvm-project
5110131a - [SelectionDAG] avoid rounding exact f32->bf16 (STRICT_)FP_ROUND (#230557)

Commit
35 days ago
[SelectionDAG] avoid rounding exact f32->bf16 (STRICT_)FP_ROUND (#230557) For f32-to-bf16, DAGTypeLegalizer::SoftPromoteHalfRes_FP_ROUND currently ignores the Trunc flag and unconditionally lowers ISD::FP_ROUND to ISD::FP_TO_BF16 as follows: - On X86 targets with +avx512bf16 or +avxneconvert, ISD::FP_TO_BF16 lowers to vcvtneps2bf16, which is lossy (it flushes subnormals to zero and quietens sNaNs.) - On targets without hardware bf16 conversion instructions, it performs rounding via a runtime libcall (e.g. __truncsfbf2) or a software rounding sequence (which can also be lossy, e.g. quieting sNaNs). The above is unnecessary and lossy; bitcasting to i32 and extracting the upper 16 bits is cheaper and lossless. Do that. Tested: ``` $ make check-llvm-codegen -j 32 [...] [100%] Running lit suite /usr/local/google/home/ecg/src/llvm-project/llvm/test/CodeGen Testing Time: 350.24s Total Discovered Tests: 32805 Unsupported : 243 (0.74%) Passed : 32505 (99.09%) Expectedly Failed: 57 (0.17%) ``` Depends on PR: https://github.com/llvm/llvm-project/pull/230698
Author
Parents
Loading