diff --git a/src/asahi/compiler/agx_minifloat.h b/src/asahi/compiler/agx_minifloat.h index d0587a40c6a..aad80b559d9 100644 --- a/src/asahi/compiler/agx_minifloat.h +++ b/src/asahi/compiler/agx_minifloat.h @@ -45,9 +45,11 @@ agx_minifloat_decode(uint8_t imm) } /* Encodes a float. Results are only valid if the float can be represented - * exactly, if not the result of this function is UNDEFINED. signbit() is used - * to ensure -0.0 is handled correctly. */ - + * exactly, if not the result of this function is UNDEFINED. However, it is + * guaranteed that this function will not crash on out-of-spec inputs, so it is + * safe to call on any input. signbit() is used to ensure -0.0 is handled + * correctly. + */ static inline uint8_t agx_minifloat_encode(float f) { @@ -63,13 +65,9 @@ agx_minifloat_encode(float f) exp -= 5; /* 2^5 = 32 */ exp = CLAMP(exp + 7, 0, 7); - assert(mantissa >= 0x10 && mantissa < 0x20); - assert(exp >= 1); - return sign | (exp << 4) | (mantissa & 0xF); } else { unsigned mantissa = (f * 64.0f); - assert(mantissa < 0x10); return sign | mantissa; }