}
} else if (instr->opcode == aco_opcode::p_demote_to_helper) {
/* turn demote into discard_if with only exact masks */
- assert((ctx.info[block->index].exec[0].second & (mask_type_exact | mask_type_global)) ==
- (mask_type_exact | mask_type_global));
+ assert(ctx.info[block->index].exec[0].second == (mask_type_exact | mask_type_global));
int num;
Temp cond, exit_cond;
}
} else {
/* demote_if: transition to exact */
- transition_to_Exact(ctx, bld, block->index);
+ if (block->kind & block_kind_top_level && ctx.info[block->index].exec.size() == 2 &&
+ ctx.info[block->index].exec.back().second & mask_type_global) {
+ /* We don't need to actually copy anything into exact, since the s_andn2
+ * instructions later will do that.
+ */
+ ctx.info[block->index].exec.pop_back();
+ } else {
+ transition_to_Exact(ctx, bld, block->index);
+ }
assert(instr->operands[0].isTemp());
cond = instr->operands[0].getTemp();
num = ctx.info[block->index].exec.size() - 1;