aco: set loop_info::has_discard for demotes
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 26 Sep 2019 09:33:43 +0000 (10:33 +0100)
committerRhys Perry <pendingchaos02@gmail.com>
Fri, 27 Sep 2019 09:57:03 +0000 (10:57 +0100)
We need the loop header phis for the outer exec masks. Needed for
dEQP-VK.glsl.demote.dynamic_loop_texture

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
src/amd/compiler/aco_insert_exec_mask.cpp
src/amd/compiler/aco_instruction_selection.cpp
src/amd/compiler/aco_ir.h

index 7886a4c77e20dae9b6150faf9d954c076df4b0a9..b423c5b9190f273ee4219d406d489a72c43bd311 100644 (file)
@@ -72,7 +72,7 @@ struct loop_info {
    uint8_t needs;
    bool has_divergent_break;
    bool has_divergent_continue;
-   bool has_discard;
+   bool has_discard; /* has a discard or demote */
    loop_info(Block* b, uint16_t num, uint8_t needs, bool breaks, bool cont, bool discard) :
              loop_header(b), num_exec_masks(num), needs(needs), has_divergent_break(breaks),
              has_divergent_continue(cont), has_discard(discard) {}
@@ -279,7 +279,8 @@ void calculate_wqm_needs(exec_ctx& exec_ctx)
 
       ever_again_needs |= exec_ctx.info[i].block_needs & ~Exact_Branch;
       if (block.kind & block_kind_discard ||
-          block.kind & block_kind_uses_discard_if)
+          block.kind & block_kind_uses_discard_if ||
+          block.kind & block_kind_uses_demote)
          ever_again_needs |= Exact;
 
       /* don't propagate WQM preservation further than the next top_level block */
@@ -629,6 +630,7 @@ void process_instructions(exec_ctx& ctx, Block* block,
                    (ctx.info[block->index].block_needs & state) !=
                    (ctx.info[block->index].block_needs & (WQM | Exact))) ||
                   block->kind & block_kind_uses_discard_if ||
+                  block->kind & block_kind_uses_demote ||
                   block->kind & block_kind_needs_lowering;
    if (!process) {
       std::vector<aco_ptr<Instruction>>::iterator it = std::next(block->instructions.begin(), idx);
@@ -811,7 +813,8 @@ void add_branch_code(exec_ctx& ctx, Block* block)
          needs |= ctx.info[i].block_needs;
 
          if (loop_block.kind & block_kind_uses_discard_if ||
-             loop_block.kind & block_kind_discard)
+             loop_block.kind & block_kind_discard ||
+             loop_block.kind & block_kind_uses_demote)
             has_discard = true;
          if (loop_block.loop_nest_depth != loop_nest_depth)
             continue;
index 7405b1142f9758cef353fb32906d1d6a933966a8..7b5dc7f742678160e2d69a77187d154a80d0ccbc 100644 (file)
@@ -5831,7 +5831,7 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr)
    }
    case nir_intrinsic_demote:
       bld.pseudo(aco_opcode::p_demote_to_helper);
-      ctx->block->kind |= block_kind_needs_lowering;
+      ctx->block->kind |= block_kind_uses_demote;
       ctx->program->needs_exact = true;
       break;
    case nir_intrinsic_demote_if: {
@@ -5839,7 +5839,7 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr)
                            as_divergent_bool(ctx, get_ssa_temp(ctx, instr->src[0].ssa), false),
                            Operand(exec, s2));
       bld.pseudo(aco_opcode::p_demote_to_helper, cond);
-      ctx->block->kind |= block_kind_needs_lowering;
+      ctx->block->kind |= block_kind_uses_demote;
       ctx->program->needs_exact = true;
       break;
    }
index 139dd1e371c895212d04c8234e0ce884645ed93e..24ff6a2b142ed6d3761c3083c71373502e1fb178 100644 (file)
@@ -924,6 +924,7 @@ enum block_kind {
    block_kind_invert = 1 << 11,
    block_kind_uses_discard_if = 1 << 12,
    block_kind_needs_lowering = 1 << 13,
+   block_kind_uses_demote = 1 << 14,
 };