[PATCH] D126953: Promote bf16 to f32 when the target doesn't support it
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 10 08:02:25 PST 2022
lebedev.ri added a comment.
FWIW, i agree with @arsenm, the legalization
================
Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:2912-2915
+ Op = DAG.getNode(
+ ISD::SHL, dl, MVT::i32, Op,
+ DAG.getConstant(16, dl,
+ TLI.getShiftAmountTy(MVT::i32, DAG.getDataLayout())));
----------------
pengfei wrote:
> arsenm wrote:
> > Why can this just shift into the high bits? Why don't the mantissa bits need to be adjusted down to the low bits?
> Expand a normal value doesn't need to adjust the mantissa bits. We do have concerns like DAZ or signaling NaN are not respected. But BF16 is not a IEEE standard type. There's no such strict rule for it AFAIK. And GCC does it in the same way.
This answer makes no sense. This expansion is an active miscompile.
The proper way to lower it is https://godbolt.org/z/GzM3n7Tdc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126953/new/
https://reviews.llvm.org/D126953
More information about the llvm-commits
mailing list