Lines Matching refs:block
40 /* The outer vectors should be indexed by block index. The inner vectors store phi information
41 * for each block. */
58 for (Block& block : ctx.program->blocks) {
59 for (aco_ptr<Instruction>& phi : block.instructions) {
72 phi->opcode == aco_opcode::p_phi ? block.logical_preds : block.linear_preds;
92 Block& block = ctx.program->blocks[block_idx];
93 unsigned idx = block.instructions.size() - 1;
94 while (block.instructions[idx]->opcode != aco_opcode::p_logical_end) {
99 std::vector<aco_ptr<Instruction>>::iterator it = std::next(block.instructions.begin(), idx);
111 block.instructions.insert(it, std::move(pc));
120 Block& block = ctx.program->blocks[block_idx];
121 std::vector<aco_ptr<Instruction>>::iterator it = block.instructions.end();
134 pc->tmp_in_scc = block.scc_live_out;
136 block.instructions.insert(it, std::move(pc));
141 is_empty_block(Block* block, bool ignore_exec_writes)
143 /* check if this block is empty and the exec mask is not needed */
144 for (aco_ptr<Instruction>& instr : block->instructions) {
171 try_remove_merge_block(ssa_elimination_ctx& ctx, Block* block)
173 /* check if the successor is another merge block which restores exec */
175 if (block->linear_succs.size() != 1 ||
176 !(ctx.program->blocks[block->linear_succs[0]].kind & block_kind_merge))
179 /* check if this block is empty */
180 if (!is_empty_block(block, true))
184 aco_ptr<Instruction> branch = std::move(block->instructions.back());
185 block->instructions.clear();
186 block->instructions.emplace_back(std::move(branch));
190 try_remove_invert_block(ssa_elimination_ctx& ctx, Block* block)
192 assert(block->linear_succs.size() == 2);
193 /* only remove this block if the successor got removed as well */
194 if (block->linear_succs[0] != block->linear_succs[1])
197 /* check if block is otherwise empty */
198 if (!is_empty_block(block, true))
201 unsigned succ_idx = block->linear_succs[0];
202 assert(block->linear_preds.size() == 2);
204 Block* pred = &ctx.program->blocks[block->linear_preds[i]];
214 block->instructions.clear();
215 block->linear_preds.clear();
216 block->linear_succs.clear();
220 try_remove_simple_block(ssa_elimination_ctx& ctx, Block* block)
222 if (!is_empty_block(block, false))
225 Block& pred = ctx.program->blocks[block->linear_preds[0]];
226 Block& succ = ctx.program->blocks[block->linear_succs[0]];
231 } else if (branch.target[0] == block->index) {
234 assert(branch.target[1] == block->index);
237 } else if (branch.target[1] == block->index) {
238 /* check if there is a fall-through path from block to succ */
239 bool falls_through = block->index < succ.index;
240 for (unsigned j = block->index + 1; falls_through && j < succ.index; j++) {
249 if (block->index >= branch.target[0])
251 for (unsigned j = block->index + 1; j < branch.target[0]; j++) {
256 /* This is a (uniform) break or continue block. The branch condition has to be inverted. */
277 if (pred.linear_succs[i] == block->index)
281 if (succ.linear_preds[i] == block->index)
284 block->instructions.clear();
285 block->linear_preds.clear();
286 block->linear_succs.clear();
300 eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block)
302 /* Check if any successor needs the outgoing exec mask from the current block. */
306 if (!ctx.logical_phi_info[block.index].empty()) {
312 for (const auto& successor_phi_info : ctx.linear_phi_info[block.index]) {
324 std::any_of(block.linear_succs.begin(), block.linear_succs.end(),
330 for (int i = block.instructions.size() - 1; i >= 0; --i) {
331 aco_ptr<Instruction>& instr = block.instructions[i];
356 /* Remember if the current block needs an incoming exec mask from its predecessors. */
357 ctx.blocks_incoming_exec_used[block.index] = exec_write_used;
360 auto new_end = std::remove(block.instructions.begin(), block.instructions.end(), nullptr);
361 block.instructions.resize(new_end - block.instructions.begin());
368 Block* block = &ctx.program->blocks[i];
369 eliminate_useless_exec_writes_in_block(ctx, *block);
374 if (block->kind & block_kind_invert) {
375 try_remove_invert_block(ctx, block);
379 if (block->linear_succs.size() > 1)
382 if (block->kind & block_kind_merge || block->kind & block_kind_loop_exit)
383 try_remove_merge_block(ctx, block);
385 if (block->linear_preds.size() == 1)
386 try_remove_simple_block(ctx, block);