fmin.s

Floating-Point Minimum-Number Single-Precision

This instruction is defined by:

Encoding

svg

Synopsis

The fmin.s instruction writes smaller of fs1 and fs2 to fd. For the purposes of this instruction, the value -0.0 is considered to be less than the value +0.0. If both inputs are NaNs, the result is the canonical NaN. If only one operand is a NaN, the result is the non-NaN operand. Signaling NaN inputs set the invalid operation exception flag, even when the result is not NaN.

Note that in version 2.2 of the F extension, the fmin.s and fmax.s instructions were amended to implement the proposed IEEE 754-201x minimumNumber and maximumNumber operations, rather than the IEEE 754-2008 minNum and maxNum operations. These operations differ in their handling of signaling NaNs.

Access

M HS U VS VU

Always

Always

Always

Always

Always

Decode Variables

Bits<5> fs2 = $encoding[24:20];
Bits<5> fs1 = $encoding[19:15];
Bits<5> fd = $encoding[11:7];

Execution

  • Pruned, XLEN == 64

  • Original

check_f_ok($encoding);
Bits<32> sp_value_a = F[fs1][31:0];
Bits<32> sp_value_b = F[fs2][31:0];
if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
  if (is_sp_signaling_nan?(sp_value_a) || is_sp_signaling_nan?(sp_value_b)) {
    set_fp_flag(FpFlag::NV);
  }
  if (is_sp_nan?(sp_value_a) && is_sp_nan?(sp_value_b)) {
    F[fd] = 32'h7fc00000;
  } else if (is_sp_nan?(sp_value_a)) {
    F[fd] = sp_value_b;
  } else {
    F[fd] = sp_value_a;
  }
} else {
  Boolean sign_a = sp_value_a[31] == 1;
  Boolean sign_b = sp_value_b[31] == 1;
  Boolean a_lt_b;
  if (sign_a != sign_b) {
    a_lt_b = sign_a;
  } else {
    a_lt_b = (sp_value_a != sp_value_b) && (sign_a != (sp_value_a < sp_value_b));
  }
  F[fd] = a_lt_b ? sp_value_a : sp_value_b;
}
mark_f_state_dirty();
check_f_ok($encoding);
Bits<32> sp_value_a = F[fs1][31:0];
Bits<32> sp_value_b = F[fs2][31:0];
if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
  if (is_sp_signaling_nan?(sp_value_a) || is_sp_signaling_nan?(sp_value_b)) {
    set_fp_flag(FpFlag::NV);
  }
  if (is_sp_nan?(sp_value_a) && is_sp_nan?(sp_value_b)) {
    F[fd] = SP_CANONICAL_NAN;
  } else if (is_sp_nan?(sp_value_a)) {
    F[fd] = sp_value_b;
  } else {
    F[fd] = sp_value_a;
  }
} else {
  Boolean sign_a = sp_value_a[31] == 1;
  Boolean sign_b = sp_value_b[31] == 1;
  Boolean a_lt_b;
  if (sign_a != sign_b) {
    a_lt_b = sign_a;
  } else {
    a_lt_b = (sp_value_a != sp_value_b) && (sign_a != (sp_value_a < sp_value_b));
  }
  F[fd] = a_lt_b ? sp_value_a : sp_value_b;
}
mark_f_state_dirty();

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction