FSET : FP32 Compare And Set

Format:

SPA 5.0:
        {@{!}Pg}   FSET{.bval}.cmp{.FTZ}       Rd{.CC}, {-}{|}Ra{|}, {-}{|}Sb{|}          {&req_6}   {?sched}   ;   
        {@{!}Pg}   FSET{.bval}.cmp{.FTZ}.bop   Rd{.CC}, {-}{|}Ra{|}, {-}{|}Sb{|}, {!}Pp   {&req_6}   {?sched}   ;   


  .bval:  { .BM*, .BF }
          Boolean mask or Boolean float value to set in Rd, default .BM

  .cmp:   { .F,   .LT,  .EQ,  .LE,  .GT,  .NE,  .GE,  .NUM,    FP32 numeric comparisons
            .NAN, .LTU, .EQU, .LEU, .GTU, .NEU, .GEU, .T   }   FP32 numeric or Unordered comparisons

 .FTZ:       Denorm inputs are flushed to sign preserving 0.0.

  .bop:   { .AND, .OR, .XOR }        Boolean op with predicate {!}Pp

  .CC:    Write condition codes

FSET allows the following source Sb:
    Sb(register)
    Sb(constant with immediate address)
    Sb(#IMM20<<12)

Description:

FSET{.bval}.cmp.bop compares register Ra and source operand Sb with FP32 comparison operation .cmp, combines the Boolean comparison result with predicate operand {!}Pp using the Boolean operation .bop, and sets the destination register Rd to integer ~0x0 or floating point 1.0f if the comparison is true, otherwise it sets Rd to 0. The Boolean operation .bop may be .AND, .OR, or .XOR, corresponding to the C Boolean operations &, |, and ^.

    if (.BM) Rd =  ( (Ra .cmp Sb) .bop {!}Pp )? 0xFFFF_FFFF: 0;     // SET Boolean mask all 1s or all 0s
    if (.BF) Rd =  ( (Ra .cmp Sb) .bop {!}Pp )? 0x3F80_0000: 0;     // SET FP32 Boolean 1.0f or 0.0f

Use .bop {!}Pp for nested conditions, with an inner comparison of Ra vs. Sb, conditioned on an outer predicate Pp.

The simple instruction format without .bop {!}Pp assembles as .AND PT, with the following effective functionality:

    if (.BM) Rd =  (Ra .cmp Sb)? 0xFFFF_FFFF: 0;     // Set Boolean mask all 1s or all 0s
    if (.BF) Rd =  (Ra .cmp Sb)? 0x3F80_0000: 0;     // Set Boolean float FP32 1.0f or 0.0f

Examples:

FSET.BF.AND R0,R1,-R2, P3, NEU;

FSET.LT           R8, R1, -R2;            // R8 = (R1 < -R2)? ~0x0: 0;
FSET.BM.LT        RZ.CC, R1, -R2;         // CC.SF = (R1 < -R2); CC.ZF = !(R1 < -R2); CC.OF = CC.CF = 0;
FSET.BF.GEU.FTZ   R8, R1, 2.5;            // R8 = ((FTZ(R1) >= 2.5) || isNan(R1))? 1.0f: 0;
FSET.EQ           R8, R1, -|c[1][0x44]|;  // R8 = (R1 == -|c[1][0x44]|)? ~0x0: 0;

FSET.LT.AND       R8, R1, R2, !P3;        // R8 = ((R1 < R2) & !P3)? ~0x0: 0;

Back to Index of Instructions