CSET : Test Condition Code And Set

Format:

SPA 5.0:
        {@{!}Pg}   CSET{.bval}.test       Rd{.CC}, CC          {&req_6}   {?sched>=?WAIT1}   ;   
        {@{!}Pg}   CSET{.bval}.test.bop   Rd{.CC}, CC, {!}Pp   {&req_6}   {?sched>=?WAIT1}   ;   

  .bval:  { .BM*, .BF }          
          Boolean mask (0xffff_ffff) or Boolean float value
          (0x3f80_0000) set in Rd for test condition met

  .test:  { .F,      .LT,     .EQ,     .LE,      .GT,      .NE,      .GE,   .NUM,     Signed numeric tests
            .NAN,    .LTU,    .EQU,    .LEU,     .GTU,     .NEU,     .GEU,  .T,       Signed or Unordered tests 
            .OFF,    .LO,     .SFF,    .LS,      .HI,      .SFT,     .HS,   .OFT,     Unsigned integer tests
            .CSM_TA, .CSM_TR, .CSM_MX, .FCSM_TA, .FCSM_TR, .FCSM_MX, .RLE,  .RGT  }   Clip State Machine tests

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

  .CC:    Write condition codes

Description:

CSET{.bval}.test.bop tests Condition Code register CC with CC.test, combines the Boolean comparison result with predicate operand {!}Pp using Boolean operation .bop, and sets 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 C Boolean operations &, |, and ^.

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

Use .bop {!}Pp for nested conditions, with an inner CC.test, conditioned on an outer predicate Pp.

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

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

Examples:

CSET.BF.NEU.AND    R0, CC, P3;

Back to Index of Instructions