fsel

Floating Select

fsel FRT,FRA,FRC,FRB

Selects FRA if FRC >= 0, else FRB (Optional).

Encoding

Binary Layout
63
0:5
FRT
6:10
FRA
11:15
FRB
16:20
FRC
21:25
23
26:30
/
31
 
Format A-form
Opcode 0xFC00002E
Extension Floating-Point

Operands

  • FRT
    Target
  • FRA
    True
  • FRC
    Cond
  • FRB
    False

Example

fsel f1, f2, f4, f3

Registers Altered

CR1, FPSCR

Related

More in Floating-Point

Reference

Description

Selects between FRA and FRB based on the sign of FRC: if FRC ≥ 0, the result is FRA; otherwise, the result is FRB. The optional dot (.) form sets CR1 based on the result's FPRF. This is an optional category instruction.

Operation

if FRC ≥ 0.0 then
  FRT ← FRA
else
  FRT ← FRB
if Rc = 1 then CR1 ← FPRF(FRT)

Programming Note

Warning: Care must be taken in using fsel if IEEE compatibility is required, or if the values being tested can be NaNs or infinities.