case float_expmax_normal:
if (unlikely(exp > exp_max)) {
/* Overflow. Return the maximum normal. */
- flags = float_flag_invalid;
+ flags = (fmt->overflow_raises_invalid
+ ? float_flag_invalid
+ : float_flag_overflow | float_flag_inexact);
exp = exp_max;
frac_allones(p);
p->frac_lo &= ~round_mask;
* The following optional modifiers are available:
* exp_max_kind: affects how exp == exp_max is interpreted
* has_explicit_bit: has an explicit integer bit; this affects whether
- * the float_status floatx80_behaviour handling applies
+ * the float_status floatx80_behaviour handling applies
+ * overflow_raises_invalid: for float_expmax_normal, raise invalid
+ * instead of overflow.
*/
typedef struct {
int exp_size;
int frac_shift;
FloatFmtExpMaxKind exp_max_kind;
bool has_explicit_bit;
+ bool overflow_raises_invalid;
uint64_t round_mask;
} FloatFmt;
static const FloatFmt float16_params_ahp = {
FLOAT_PARAMS(5, 10),
.exp_max_kind = float_expmax_normal,
+ .overflow_raises_invalid = true,
};
static const FloatFmt bfloat16_params = {