Skip to content

Commit 85fb1da

Browse files
committed
Review comments: use sycl::bit_cast instead of union-based hack.
1 parent f1b19ae commit 85fb1da

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

sycl/include/sycl/ext/oneapi/experimental/bfloat16.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,9 @@ class bfloat16 {
6363
return __spirv_ConvertBF16ToFINTEL(a);
6464
#endif
6565
#else
66-
union {
67-
uint32_t bits;
68-
float res;
69-
} val;
70-
val.bits = a;
71-
val.bits <<= 16;
72-
return val.res;
66+
uint32_t bits = a;
67+
bits <<= 16;
68+
return sycl::bit_cast<float>(bits);
7369
#endif
7470
}
7571

0 commit comments

Comments
 (0)