/* IF instructions, by definition, can only be found at the ends of
* basic blocks.
*/
- fs_inst *if_inst = (fs_inst *) block->end;
+ fs_inst *if_inst = (fs_inst *)block->end();
if (if_inst->opcode != BRW_OPCODE_IF)
continue;
- if (!block->else_block)
- continue;
-
- assert(block->else_block->end->opcode == BRW_OPCODE_ELSE);
-
fs_inst *else_mov[MAX_MOVS] = { NULL };
fs_inst *then_mov[MAX_MOVS] = { NULL };
- bblock_t *then_block = (bblock_t *)block->link.next;
- bblock_t *else_block = (bblock_t *)block->else_block->link.next;
+ bblock_t *then_block = block->next();
+ bblock_t *else_block = NULL;
+ foreach_list_typed(bblock_link, child, link, &block->children) {
+ if (child->block != then_block) {
+ if (child->block->prev()->end()->opcode == BRW_OPCODE_ELSE) {
+ else_block = child->block;
+ }
+ break;
+ }
+ }
+ if (else_block == NULL)
+ continue;
int movs = count_movs_from_if(then_mov, else_mov, then_block, else_block);
enum brw_predicate predicate;
bool predicate_inverse;
- if (brw->gen == 6 && if_inst->conditional_mod) {
+ if (devinfo->gen == 6 && if_inst->conditional_mod) {
/* For Sandybridge with IF with embedded comparison */
predicate = BRW_PREDICATE_NORMAL;
predicate_inverse = false;
/* Check that the MOVs are the right form. */
if (!then_mov[i]->dst.equals(else_mov[i]->dst) ||
then_mov[i]->is_partial_write() ||
- else_mov[i]->is_partial_write()) {
+ else_mov[i]->is_partial_write() ||
+ then_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE ||
+ else_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE) {
movs = i;
break;
}
*/
fs_reg src0(then_mov[i]->src[0]);
if (src0.file == IMM) {
- src0 = fs_reg(this, glsl_type::float_type);
+ src0 = vgrf(glsl_type::float_type);
src0.type = then_mov[i]->src[0].type;
mov_imm_inst[i] = MOV(src0, then_mov[i]->src[0]);
}
continue;
/* Emit a CMP if our IF used the embedded comparison */
- if (brw->gen == 6 && if_inst->conditional_mod) {
+ if (devinfo->gen == 6 && if_inst->conditional_mod) {
fs_inst *cmp_inst = CMP(reg_null_d, if_inst->src[0], if_inst->src[1],
if_inst->conditional_mod);
if_inst->insert_before(block, cmp_inst);