aco: rework barriers and replace can_reorder
[mesa.git] / src / amd / compiler / aco_dead_code_analysis.cpp
index f56718f0479f87f933e8335d0923657f0b0893a4..f43d784c55f69fe5434603924d8ae47d1abaa7a5 100644 (file)
@@ -57,11 +57,7 @@ void process_block(dce_ctx& ctx, Block& block)
          continue;
 
       aco_ptr<Instruction>& instr = block.instructions[idx];
-      const bool is_live = instr->definitions.empty() ||
-                           std::any_of(instr->definitions.begin(), instr->definitions.end(),
-                              [&ctx] (const Definition& def) { return !def.isTemp() || ctx.uses[def.tempId()];});
-
-      if (is_live) {
+      if (!is_dead(ctx.uses, instr.get())) {
          for (const Operand& op : instr->operands) {
             if (op.isTemp()) {
                if (ctx.uses[op.tempId()] == 0)
@@ -81,6 +77,16 @@ void process_block(dce_ctx& ctx, Block& block)
 
 } /* end namespace */
 
+bool is_dead(const std::vector<uint16_t>& uses, Instruction *instr)
+{
+   if (instr->definitions.empty())
+      return false;
+   if (std::any_of(instr->definitions.begin(), instr->definitions.end(),
+          [&uses] (const Definition& def) { return uses[def.tempId()];}))
+      return false;
+   return !(get_sync_info(instr).semantics & (semantic_volatile | semantic_acqrel));
+}
+
 std::vector<uint16_t> dead_code_analysis(Program *program) {
 
    dce_ctx ctx(program);