On Wed, Nov 23, 2022 at 8:40 PM Jakub Jelinek <ja...@redhat.com> wrote: > > On Wed, Nov 23, 2022 at 08:28:20PM +0800, liuhongt via Gcc-patches wrote: > > After supporting real __bf16 type, implementation of mm_cvtsbh_ss went > > wrong. > > The patch supports extendbfsf2/truncsfbf2 with pslld/psrld, > > and then refined the intrinsic with implicit conversion. > > This is not correct. > While using such code for _mm_cvtsbh_ss is fine if it is documented not to > raise exceptions and turn a sNaN into a qNaN, it is not fine for HONOR_NANS > (i.e. when -ffast-math is not on), because a __bf16 -> float conversion > on sNaN should raise invalid exception and turn it into a qNaN. > We could have extendbfsf2 expander that would FAIL; if HONOR_NANS and > emit extendbfsf2_1 otherwise. I see, i'll use target specific builtin and generate psrld just for the intrinsic, and drop the expander part. > > And the truncsfbf2 case isn't correct IMHO even for -ffast-math. > float -> __bf16 conversion should be properly rounding depending on the > current rounding mode, while {,v}psrld will always round toward zero. > > Jakub >
-- BR, Hongtao