Lines Matching defs:instr
42 bool operator==(const Idx& other) const { return block == other.block && instr == other.instr; }
48 uint32_t instr;
116 Instruction* get(Idx idx) { return program->blocks[idx.block].instructions[idx.instr].get(); }
120 save_reg_writes(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
122 for (const Definition& def : instr->definitions) {
189 if (i.block > idx.block || (i.block == idx.block && i.instr > idx.instr))
204 try_apply_branch_vcc(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
211 * s_cbranch_XX scc ; instr
216 * s_cbranch_XX vcc ; instr modified to use vcc
223 if (instr->format != Format::PSEUDO_BRANCH || instr->operands.size() == 0 ||
224 instr->operands[0].physReg() != scc)
227 Idx op0_instr_idx = last_writer_idx(ctx, instr->operands[0]);
256 ctx.uses[instr->operands[0].tempId()]--;
258 instr->operands[0] = op0_instr->operands[0];
262 try_optimize_scc_nocompare(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
277 if (!instr->isSALU() && !instr->isBranch())
280 if (instr->isSOPC() &&
281 (instr->opcode == aco_opcode::s_cmp_eq_u32 || instr->opcode == aco_opcode::s_cmp_eq_i32 ||
282 instr->opcode == aco_opcode::s_cmp_lg_u32 || instr->opcode == aco_opcode::s_cmp_lg_i32 ||
283 instr->opcode == aco_opcode::s_cmp_eq_u64 || instr->opcode == aco_opcode::s_cmp_lg_u64) &&
284 (instr->operands[0].constantEquals(0) || instr->operands[1].constantEquals(0)) &&
285 (instr->operands[0].isTemp() || instr->operands[1].isTemp())) {
287 if (instr->operands[0].isConstant())
288 std::swap(instr->operands[0], instr->operands[1]);
290 if (ctx.uses[instr->operands[0].tempId()] > 1)
294 Idx wr_idx = last_writer_idx(ctx, instr->operands[0]);
340 ctx.uses[instr->operands[0].tempId()]--;
341 instr->operands[0] = Operand(wr_instr->definitions[1].getTemp(), scc);
342 ctx.uses[instr->operands[0].tempId()]++;
345 instr->operands[1] = Operand::zero();
346 instr->opcode =
347 (instr->opcode == aco_opcode::s_cmp_eq_u32 || instr->opcode == aco_opcode::s_cmp_eq_i32 ||
348 instr->opcode == aco_opcode::s_cmp_eq_u64)
351 } else if ((instr->format == Format::PSEUDO_BRANCH && instr->operands.size() == 1 &&
352 instr->operands[0].physReg() == scc) ||
353 instr->opcode == aco_opcode::s_cselect_b32) {
357 if (instr->opcode == aco_opcode::s_cselect_b32) {
361 Idx wr_idx = last_writer_idx(ctx, instr->operands[scc_op_idx]);
377 if (ctx.uses[instr->operands[scc_op_idx].tempId()] > 1)
382 if (instr->format == Format::PSEUDO_BRANCH)
383 instr->opcode = instr->opcode == aco_opcode::p_cbranch_z ? aco_opcode::p_cbranch_nz
385 else if (instr->opcode == aco_opcode::s_cselect_b32)
386 std::swap(instr->operands[0], instr->operands[1]);
393 ctx.uses[instr->operands[scc_op_idx].tempId()]--;
394 instr->operands[scc_op_idx] = wr_instr->operands[0];
399 try_combine_dpp(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
404 * v_xxx vC, vA, ... ; current instr that uses the result from the move
408 * v_xxx_dpp vC, vB, ... ; current instr modified to use DPP directly
412 if (!instr->isVALU() || instr->isDPP())
415 for (unsigned i = 0; i < MIN2(2, instr->operands.size()); i++) {
416 Idx op_instr_idx = last_writer_idx(ctx, instr->operands[i]);
424 if (!can_use_DPP(instr, false, dpp8))
438 if (i && !can_swap_operands(instr, &instr->opcode))
447 convert_to_DPP(instr, dpp8);
450 DPP8_instruction* dpp = &instr->dpp8();
457 DPP16_instruction* dpp = &instr->dpp16();
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);
482 if (instr)
483 save_reg_writes(ctx, instr);
505 for (aco_ptr<Instruction>& instr : block.instructions)
506 process_instruction(ctx, instr);
515 [&ctx](const aco_ptr<Instruction>& instr)
516 { return !instr || is_dead(ctx.uses, instr.get()); });