Clamping (Limit) Functions

Although not specified in any IEEE 754 standard, the ISA supports a clamping (or limit) instruction (FFLIM) intended for use where an input operand needs to be constrained between an upper and lower limit. It serves a similar purpose to the integer equivalent FLIM instruction and is essentially a concurrent execution of FMIN and FMAX operations with a common operand. Refer to the truth table shown in Table 6-37 for a definition of how NaN operands are handled.

Any finite operand value will compare as less than +infinity or greater than -infinity. Operand value of -0 compares to less than +0.

For FFLIM operations, when both upper and lower limits are either both qNaN or both sNaN values, a NaN significand comparison (to select result NaN source) is not required, and the Fb NaN will be the default source for the result. This differs from how coincident NaN values are treated in general.

Furthermore, a NaN input value (Fd) will cause the limit values to be ignored and will become the source for the result. That is, checks between input NaNs and limit values (NaNs or otherwise) are also not required.
Table 6-37. FFLIM Operation
Fb(3)

(Lower Limit)

Fs(3)

(Upper Limit)

Fd

(Input Value)

Invalid Exception MaskFd

(Result)

FSR.INVALException Taken?
FPNLFPNUFPNDon’t careFPNL or FPNU or FPN(2)or Distinguished qNaN(3)0No
FPNLqNaN_UFPNDon’t careqNaN_U0No
FPNLsNaN_UFPN1Quieted sNaN_U1No
0Yes
qNaN_LFPNUFPNDon’t careqNaN_L0No
sNaN_LFPNUFPN1Quieted sNaN_L1No
0Yes
sNaN_LsNaN_UFPN1Quieted sNaN_L(5)1No
0Yes
sNaN_LqNaN_UFPN1qNaN_U(6)1No
0Yes
qNaN_LsNaN_UFPN1qNaN_L(6)1No
0Yes
qNaN_LqNaN_UFPNDon’t careqNaN_L(5)0No
Don’t careDon’t caresNaN1Quieted sNaN(7)1No
0Yes
Don’t careDon’t careqNaNDon’t careqNaN0No
Note:
  1. FPNL and FPNU are floating-point numbers that are not a NaN.
  2. Result determined by FFLIM operation.
  3. If Fs is less than Fb (and neither Fs nor Fb are NaN values), the result will be the distinguished qNaN, and the Invalid exception will be signaled.
  4. FFLIM operation based on IEEE 754-2019 minimum(x,y) and maximum(x,y) operation definitions.
  5. Unlike FMIN/FMAX operations, no magnitude comparison of limit NaN values is required. Default result will always be sourced from Fb.
  6. qNaN values have priority over sNaN values (see Table 6-38).
  7. Unlike FMIN/FMAX operations, no comparison of limit and input (Fd) values is required. Default result will always be sourced from Fd.