aco: implement <32-bit masked_swizzle_amd
[mesa.git] / src / amd / compiler / aco_ssa_elimination.cpp
index 94f5a1ade8384ba0816eb9ef0464375b939c0b2c..23963d5b95caa09ff66e525222d6120c1bae6b22 100644 (file)
@@ -207,7 +207,7 @@ void try_remove_simple_block(ssa_elimination_ctx& ctx, Block* block)
       branch->opcode = aco_opcode::p_branch;
    } else if (branch->target[1] == block->index) {
       /* check if there is a fall-through path from block to succ */
-      bool falls_through = true;
+      bool falls_through = block->index < succ.index;
       for (unsigned j = block->index + 1; falls_through && j < succ.index; j++) {
          assert(ctx.program->blocks[j].index == j);
          if (!ctx.program->blocks[j].instructions.empty())
@@ -217,6 +217,8 @@ void try_remove_simple_block(ssa_elimination_ctx& ctx, Block* block)
          branch->target[1] = succ.index;
       } else {
          /* check if there is a fall-through path for the alternative target */
+         if (block->index >= branch->target[0])
+            return;
          for (unsigned j = block->index + 1; j < branch->target[0]; j++) {
             if (!ctx.program->blocks[j].instructions.empty())
                return;