[llvm] [X86] Add support for `__bf16` to `f16` conversion (PR #134859)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 26 10:28:36 PDT 2025
antoniofrighetto wrote:
@phoebewang Thanks for the suggestion (and sorry for getting back only now), agree we should be using the already-existing `FR16X` register class, updated affected patterns (first fixup commit)!
In the second fixup commit, I took the chance to add custom hook for extension/truncation: while `fptrunc` is already handled correctly (https://llvm.godbolt.org/z/K87Tor8qP), I don't think that is the case for `fpext` (redundant shift of bits + call to `__truncsfbf2`, which shouId just be a call to `__extendbfsf2`), though I believe this should be orthogonal to the current miscompilation (might as well add in a different patch if any).
I tried to restrain the changes to FastISel only, however, even so, there were some other patterns to be added. There are some test failures mostly related to missing instruction selection for some nodes, e.g., `bf16 = ConstantFP<APFloat(0)>` (think we miss some move pattern here, this comes due to the fact that a `v32f16 = BUILD_VECTOR` node of 32 `ConstantFP:f16<APFloat(0)>` elements should have been correctly replaced with a single `v32f16 = X86ISD::VBROADCAST ConstantFP:bf16<APFloat(0)>`), but if possible it'd be nice to confirm this is the correct direction before.
https://github.com/llvm/llvm-project/pull/134859
More information about the llvm-commits
mailing list