https://godbolt.org/z/exb7PbjnK C++ code: ```cpp _Float16 fabsf16(_Float16 x) { return __builtin_bit_cast( _Float16, static_cast<unsigned short>( __builtin_bit_cast(unsigned short, x) & 0x7fff ) ); } ``` IR: ```llvm define dso_local noundef half @fabsf16(_Float16)(half noundef %x) local_unnamed_addr { entry: %0 = bitcast half %x to i16 %1 = and i16 %0, 32767 %2 = bitcast i16 %1 to half ret half %2 } ``` Clang 16 output assembly with `-O3`: ```asm fabsf16(_Float16): pextrw eax, xmm0, 0 and eax, 32767 pinsrw xmm0, eax, 0 ret ``` Clang 17 output assembly with `-O3`: ```asm .LCPI0_0: .long 0x7fffffff .long 0x7fffffff .long 0x7fffffff .long 0x7fffffff fabsf16(_Float16): push rax call __extendhfsf2@PLT andps xmm0, xmmword ptr [rip + .LCPI0_0] call __truncsfhf2@PLT pop rax ret ``` Related: https://github.com/llvm/llvm-project/pull/104869#issuecomment-2297563670. cc @arsenm @lntue