Webcentive RISC-V Reference

fleq.s

Floating-Point Less Than or Equal Quiet Single-Precision

Extension
F, Zfa
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
fleq.s xd, fs1, fs2
Length
32-bit

Encoding

312726252420191514121176210
1010000rs2rs1100rd1010011

Match 0xa0004053, mask 0xfe00707f. Source: fleq.s rd rs1 rs2 31..27=0x14 14..12=4 26..25=0 6..2=0x14 1..0=3 in riscv-opcodes/extensions/rv_f_zfa.

FieldBitsriscv-opcodes name
rs224:20rs2
rs119:15rs1
rd11:7rd

Description

The fleq.s instruction is defined like the fle.s instruction, except that quiet NaN inputs do not cause the invalid operation exception flag to be set.

Description from riscv-unified-db, reformatted.

Operation

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)) {
  # Quiet comparison: only set NV for signaling NaN
  if (is_sp_signaling_nan?(sp_value_a) || is_sp_signaling_nan?(sp_value_b)) {
    set_fp_flag(FpFlag::NV);
  }
  X[xd] = 0;
} else {
  Boolean sign_a = sp_value_a[31] == 1;
  Boolean sign_b = sp_value_b[31] == 1;

  # Check equality first (including -0.0 == +0.0)
  Boolean a_eq_b =
    (sp_value_a == sp_value_b)
    || ((sp_value_a | sp_value_b)[30:0] == 0);

  # Check a < b
  Boolean a_lt_b;
  if (sign_a != sign_b) {
    a_lt_b = sign_a && ((sp_value_a[30:0] | sp_value_b[30:0]) != 0);
  } else {
    a_lt_b = (sp_value_a != sp_value_b) && (sign_a != (sp_value_a < sp_value_b));
  }

  X[xd] = (a_lt_b || a_eq_b) ? 1 : 0;
}

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages