Lines Matching refs:ctx
120 save_reg_writes(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
128 Idx idx{ctx.current_block->index, ctx.current_instr_idx};
135 std::fill(ctx.instr_idx_by_regs[ctx.current_block->index].begin() + r,
136 ctx.instr_idx_by_regs[ctx.current_block->index].begin() + r + dw_size, idx);
141 last_writer_idx(pr_opt_ctx& ctx, PhysReg physReg, RegClass rc)
145 Idx instr_idx = ctx.instr_idx_by_regs[ctx.current_block->index][physReg.reg()];
149 std::all_of(ctx.instr_idx_by_regs[ctx.current_block->index].begin() + r,
150 ctx.instr_idx_by_regs[ctx.current_block->index].begin() + r + dw_size,
157 last_writer_idx(pr_opt_ctx& ctx, const Operand& op)
162 return last_writer_idx(ctx, op.physReg(), op.regClass());
166 is_clobbered_since(pr_opt_ctx& ctx, PhysReg reg, RegClass rc, const Idx& idx)
178 unsigned current_block_idx = ctx.current_block->index;
181 Idx& i = ctx.instr_idx_by_regs[current_block_idx][r];
198 is_clobbered_since(pr_opt_ctx& ctx, const T& t, const Idx& idx)
200 return is_clobbered_since(ctx, t.physReg(), t.regClass(), idx);
204 try_apply_branch_vcc(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
220 if (ctx.program->gfx_level < GFX8)
227 Idx op0_instr_idx = last_writer_idx(ctx, instr->operands[0]);
228 Idx last_vcc_wr_idx = last_writer_idx(ctx, vcc, ctx.program->lane_mask);
238 op0_instr_idx.block != ctx.current_block->index ||
239 last_vcc_wr_idx.block != ctx.current_block->index ||
240 is_clobbered_since(ctx, exec, ctx.program->lane_mask, last_vcc_wr_idx) ||
241 is_clobbered_since(ctx, vcc, ctx.program->lane_mask, op0_instr_idx))
244 Instruction* op0_instr = ctx.get(op0_instr_idx);
245 Instruction* last_vcc_wr = ctx.get(last_vcc_wr_idx);
256 ctx.uses[instr->operands[0].tempId()]--;
262 try_optimize_scc_nocompare(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
290 if (ctx.uses[instr->operands[0].tempId()] > 1)
294 Idx wr_idx = last_writer_idx(ctx, instr->operands[0]);
295 Idx sccwr_idx = last_writer_idx(ctx, scc, s1);
299 Instruction* wr_instr = ctx.get(wr_idx);
340 ctx.uses[instr->operands[0].tempId()]--;
342 ctx.uses[instr->operands[0].tempId()]++;
361 Idx wr_idx = last_writer_idx(ctx, instr->operands[scc_op_idx]);
365 Instruction* wr_instr = ctx.get(wr_idx);
377 if (ctx.uses[instr->operands[scc_op_idx].tempId()] > 1)
393 ctx.uses[instr->operands[scc_op_idx].tempId()]--;
399 try_combine_dpp(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
416 Idx op_instr_idx = last_writer_idx(ctx, instr->operands[i]);
420 const Instruction* mov = ctx.get(op_instr_idx);
431 (!mov->definitions[0].tempId() || ctx.uses[mov->definitions[0].tempId()] > 1))
435 if (is_clobbered_since(ctx, mov->operands[0], op_instr_idx))
444 if (--ctx.uses[mov->definitions[0].tempId()])
445 ctx.uses[mov->operands[0].tempId()]++;
474 process_instruction(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
476 try_apply_branch_vcc(ctx, instr);
478 try_optimize_scc_nocompare(ctx, instr);
480 try_combine_dpp(ctx, instr);
483 save_reg_writes(ctx, instr);
485 ctx.current_instr_idx++;
493 pr_opt_ctx ctx;
494 ctx.program = program;
495 ctx.uses = dead_code_analysis(program);
496 ctx.instr_idx_by_regs.resize(program->blocks.size());
503 ctx.reset_block(&block);
506 process_instruction(ctx, instr);
515 [&ctx](const aco_ptr<Instruction>& instr)
516 { return !instr || is_dead(ctx.uses, instr.get()); });