[llvm] [APFloat] Fix sign bit corrupting exponent in unsigned FP8 formats (PR #223286)

Hung-Kuan Tseng via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 08:52:09 PDT 2026


https://github.com/Tim096 commented:

LGTM from the side of #216056, which added this test. I double-checked why the value has to change: with -2.0 the biased exponent is already 0x80 in both formats, so OR-ing the sign bit in is invisible; with -1.0 it turns E8M0FNU's 0x7f into 0xff (the NaN encoding) and E5M3FNU's 0x78 into 0xf8.

For the follow-up from @tgymnich's list: the root cause is that `convert()` reports the lost sign but leaves `sign` set, so `bitwiseIsEqual` and `hash_value` still tell -1.0 and 1.0 apart in these formats even though their bits are now the same. I'll look at clearing the sign there, which may also take care of the two asserts, since the Inf/NaN paths pass that sign on to `makeNaN`.


https://github.com/llvm/llvm-project/pull/223286


More information about the llvm-commits mailing list