| 174 | <h4>S_CBRANCH_I_FORK</h4> |
| 175 | <p>Opcode: 17 (0x11) for GCN 1.0/1.1; 16 (0x10) for GCN 1.2<br /> |
| 176 | Syntax: S_CBRANCH_I_FORK SSRC0(2), RELADDR<br /> |
| 177 | Description: Fork control flow to passed and failed condition, jump to address RELADDR for |
| 178 | passed conditions. Make two masks: for passed conditions (EXEC & SSRC0), |
| 179 | for failed conditions: (EXEC & ~SSRC0). |
| 180 | Choose way that have smallest active threads and push data for second way to control stack |
| 181 | (EXEC mask, jump address). Control stack pointer is stored in CSP |
| 182 | (3 last bits in MODE register). One entry of the stack have 4 dwords. |
| 183 | This instruction doesn't work if SSRC0 is immediate value.<br /> |
| 184 | Operation:<br /> |
| 185 | <code>UINT64 passes = (EXEC & SSRC0) |
| 186 | UINT64 failures = (EXEC & ~SSRC0) |
| 187 | if (passes == EXEC) |
| 188 | PC = SSRC1 |
| 189 | else if (failures == EXEC) |
| 190 | PC += 4 |
| 191 | else if (BITCOUNT(failures) < BITCOUNT(passes)) { |
| 192 | EXEC = failures |
| 193 | SGPR[CSP*4:CSP*4+1] = passes |
| 194 | SGPR[CSP*4+2:CSP*4+3] = RELADDR |
| 195 | CSP++ |
| 196 | PC += 4 /* jump to failure */ |
| 197 | } else { |
| 198 | EXEC = passes |
| 199 | SGPR[CSP*4:CSP*4+1] = failures |
| 200 | SGPR[CSP*4+2:CSP*4+3] = PC+4 |
| 201 | CSP++ |
| 202 | PC = RELADDR /* jump to passes */ |
| 203 | }</code></p> |