https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106652
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #53557|0 |1 is obsolete| | Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Last reconfirmed| |2022-09-10 Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 --- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 53558 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53558&action=edit gcc13-pr106652.patch The other conversion better should use backend support if available, but could be implemented in libgcc __truncsfbf2 or inline. I believe Intel docs document it as __bf16 __truncsfbf2 (_Float32 x) { unsigned int y; memcpy (&y, &x, sizeof (y)); unsigned int z = x & 0x7fffffff; unsigned short r; __bf16 ret; if (z < 0x800000) // Zero or denormal, flush to zero. r = (x & 0x80000000) >> 16; else if (z < 0x7f800000) // Normal, round to nearest. r = (x + 0x7fff + ((x >> 16) & 1)) >> 16; else if (z == 0x7f800000) // Inf. r = x >> 16; else // NaN. r = (x >> 16) | (1 << 6); memcpy (&ret, &r, sizeof (r)); return ret; }