public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/107748] New: [13 Regression] Isn't _mm_cvtsbh_ss incorrect?
@ 2022-11-18 10:10 jakub at gcc dot gnu.org
  2022-11-18 10:11 ` [Bug target/107748] " jakub at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-11-18 10:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107748

            Bug ID: 107748
           Summary: [13 Regression] Isn't _mm_cvtsbh_ss incorrect?
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

The implementation:

/* Convert One BF16 Data to One Single Float Data.  */
extern __inline float
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtsbh_ss (__bf16 __A)
{
  union{ float a; unsigned int b;} __tmp;
  __tmp.b = ((unsigned int)(__A)) << 16;
  return __tmp.a;
}

except for the __bfloat16 -> __bf16 change used to be correct in GCC 12,
if one can ignore sNaN (and I presume the builtin is ok with that), then when
__A argument was actually unsigned or signed short, the above did the right
thing.
But now it certainly doesn't, because it converts the floating point BFmode
__A to integer, then shifts the integer 16 bits up and then VIEW_CONVERT_EXPRs
it into float.  So, instead of -ffinite-math-only BF -> SF conversion it
actually
does BF -> SF -> USI conversions, then multiplies by 65536 and then VCE to SF.
So, either it can just do return __A; but that will emit a library call unless
-ffinite-math-only/-ffast-math, or it could be e.g.
  unsigned short int __b;
  unsigned int __c;
  float __ret;
  __builtin_memcpy (&__b, &__A, sizeof (__b));
  __c = __b << 16;
  __builtin_memcpy (&__ret, &__c, sizeof (__ret));
  return __ret;
Note, the a and b identifiers in the union look bad as well, a and b aren't
reserved identifiers...

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-05-03 15:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 10:10 [Bug target/107748] New: [13 Regression] Isn't _mm_cvtsbh_ss incorrect? jakub at gcc dot gnu.org
2022-11-18 10:11 ` [Bug target/107748] " jakub at gcc dot gnu.org
2022-11-18 10:14 ` jakub at gcc dot gnu.org
2022-11-18 11:31 ` crazylht at gmail dot com
2022-11-18 11:46 ` jakub at gcc dot gnu.org
2022-11-18 12:04 ` jakub at gcc dot gnu.org
2022-11-21  9:30 ` cvs-commit at gcc dot gnu.org
2022-11-21  9:33 ` cvs-commit at gcc dot gnu.org
2022-11-21  9:35 ` cvs-commit at gcc dot gnu.org
2022-11-21  9:36 ` jakub at gcc dot gnu.org
2022-11-22  5:16 ` crazylht at gmail dot com
2022-11-28  1:03 ` cvs-commit at gcc dot gnu.org
2022-11-28  1:03 ` crazylht at gmail dot com
2022-11-29 14:41 ` jakub at gcc dot gnu.org
2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).