[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 11:35:55 PST 2022
lebedev.ri added a comment.
In D126953#3986502 <https://reviews.llvm.org/D126953#3986502>, @craig.topper wrote:
> In D126953#3986425 <https://reviews.llvm.org/D126953#3986425>, @lebedev.ri wrote:
>
>> FWIW, i agree with @arsenm, the legalization is wrong.
>
> The lowering is correct. Mantissa for ieee numbers are normalized by shifting left to avoid storing the first 1.
>
> Consider the number 1.5. In f32 it is stored as 0x3fc00000
> sign = 0
> exponent = 127
> mantissa = 0x400000
>
> 1.5 in bfloat16 is 0x3fc0
> sign = 0
> exponent = 127
> mantissa = 0x400
Ok, i forgot that bit (i even implemented similar widening elsewhere previously!).
So yes, this is identical except for subnormals
- no subnormal normalization https://godbolt.org/z/TTqf9PeGc https://godbolt.org/z/TTqf9PeGc
- with subnormal normalization https://godbolt.org/z/K88vh4xc8 https://alive2.llvm.org/ce/z/WeFY75
My apologies...
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