Mesa (main): Re-indentation after the previous commit

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 11 17:59:13 UTC 2022


Module: Mesa
Branch: main
Commit: 59889eb3ae6a1bd68697471fd887c94b65aa93d8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=59889eb3ae6a1bd68697471fd887c94b65aa93d8

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jan 14 19:12:24 2022 -0800

Re-indentation after the previous commit

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>

---

 src/compiler/glsl/glsl_to_nir.cpp             |   5 +-
 src/compiler/glsl/lower_if_to_cond_assign.cpp |  26 ++--
 src/compiler/glsl/opt_dead_code_local.cpp     | 184 +++++++++++++-------------
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp    |  12 +-
 4 files changed, 114 insertions(+), 113 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 180b2c115e7..43abb35812f 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -1757,8 +1757,9 @@ nir_visitor::visit(ir_assignment *ir)
    }
 
    enum gl_access_qualifier qualifiers = deref_get_qualifier(lhs_deref);
-      nir_store_deref_with_access(&b, lhs_deref, src, write_mask,
-                                  qualifiers);
+
+   nir_store_deref_with_access(&b, lhs_deref, src, write_mask,
+                               qualifiers);
 }
 
 /*
diff --git a/src/compiler/glsl/lower_if_to_cond_assign.cpp b/src/compiler/glsl/lower_if_to_cond_assign.cpp
index ad6f03901c4..8f1e800b888 100644
--- a/src/compiler/glsl/lower_if_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_if_to_cond_assign.cpp
@@ -193,19 +193,19 @@ move_block_to_cond_assign(void *mem_ctx,
                _mesa_set_search(
                   set, assign->lhs->variable_referenced()) != NULL;
 
-               if (assign_to_cv) {
-                  assign->rhs =
-                     new(mem_ctx) ir_expression(ir_binop_logic_and,
-                                                glsl_type::bool_type,
-                                                cond_expr->clone(mem_ctx, NULL),
-                                                assign->rhs);
-               } else {
-                  assign->rhs =
-                     new(mem_ctx) ir_expression(ir_triop_csel,
-                                                cond_expr->clone(mem_ctx, NULL),
-                                                assign->rhs,
-                                                assign->lhs->as_dereference());
-               }
+            if (assign_to_cv) {
+               assign->rhs =
+                  new(mem_ctx) ir_expression(ir_binop_logic_and,
+                                             glsl_type::bool_type,
+                                             cond_expr->clone(mem_ctx, NULL),
+                                             assign->rhs);
+            } else {
+               assign->rhs =
+                  new(mem_ctx) ir_expression(ir_triop_csel,
+                                             cond_expr->clone(mem_ctx, NULL),
+                                             assign->rhs,
+                                             assign->lhs->as_dereference());
+            }
          }
       }
 
diff --git a/src/compiler/glsl/opt_dead_code_local.cpp b/src/compiler/glsl/opt_dead_code_local.cpp
index 746c6d5f76d..b89519b8e27 100644
--- a/src/compiler/glsl/opt_dead_code_local.cpp
+++ b/src/compiler/glsl/opt_dead_code_local.cpp
@@ -175,14 +175,14 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
    bool progress = false;
    kill_for_derefs_visitor v(assignments);
 
-      /* If this is an assignment of the form "foo = foo;", remove the whole
-       * instruction and be done with it.
-       */
-      const ir_variable *const lhs_var = ir->whole_variable_written();
-      if (lhs_var != NULL && lhs_var == ir->rhs->whole_variable_referenced()) {
-         ir->remove();
-         return true;
-      }
+   /* If this is an assignment of the form "foo = foo;", remove the whole
+    * instruction and be done with it.
+    */
+   const ir_variable *const lhs_var = ir->whole_variable_written();
+   if (lhs_var != NULL && lhs_var == ir->rhs->whole_variable_referenced()) {
+      ir->remove();
+      return true;
+   }
 
    /* Kill assignment entries for things used to produce this assignment. */
    ir->rhs->accept(&v);
@@ -194,93 +194,93 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
    assert(var);
 
    /* Now, check if we did a whole-variable assignment. */
-      ir_dereference_variable *deref_var = ir->lhs->as_dereference_variable();
+   ir_dereference_variable *deref_var = ir->lhs->as_dereference_variable();
 
-      /* If it's a vector type, we can do per-channel elimination of
-       * use of the RHS.
+   /* If it's a vector type, we can do per-channel elimination of
+    * use of the RHS.
+    */
+   if (deref_var && (deref_var->var->type->is_scalar() ||
+                     deref_var->var->type->is_vector())) {
+
+      if (debug)
+         printf("looking for %s.0x%01x to remove\n", var->name,
+                ir->write_mask);
+
+      foreach_in_list_safe(assignment_entry, entry, assignments) {
+         if (entry->lhs != var)
+            continue;
+
+         /* Skip if the assignment we're trying to eliminate isn't a plain
+          * variable deref. */
+         if (entry->ir->lhs->ir_type != ir_type_dereference_variable)
+            continue;
+
+         int remove = entry->unused & ir->write_mask;
+         if (debug) {
+            printf("%s 0x%01x - 0x%01x = 0x%01x\n",
+                   var->name,
+                   entry->ir->write_mask,
+                   remove, entry->ir->write_mask & ~remove);
+         }
+         if (remove) {
+            progress = true;
+
+            if (debug) {
+               printf("rewriting:\n  ");
+               entry->ir->print();
+               printf("\n");
+            }
+
+            entry->ir->write_mask &= ~remove;
+            entry->unused &= ~remove;
+            if (entry->ir->write_mask == 0) {
+               /* Delete the dead assignment. */
+               entry->ir->remove();
+               entry->remove();
+            } else {
+               void *mem_ctx = ralloc_parent(entry->ir);
+               /* Reswizzle the RHS arguments according to the new
+                * write_mask.
+                */
+               unsigned components[4];
+               unsigned channels = 0;
+               unsigned next = 0;
+
+               for (int i = 0; i < 4; i++) {
+                  if ((entry->ir->write_mask | remove) & (1 << i)) {
+                     if (!(remove & (1 << i)))
+                        components[channels++] = next;
+                     next++;
+                  }
+               }
+
+               entry->ir->rhs = new(mem_ctx) ir_swizzle(entry->ir->rhs,
+                                                        components,
+                                                        channels);
+               if (debug) {
+                  printf("to:\n  ");
+                  entry->ir->print();
+                  printf("\n");
+               }
+            }
+         }
+      }
+   } else if (ir->whole_variable_written() != NULL) {
+      /* We did a whole-variable assignment.  So, any instruction in
+       * the assignment list with the same LHS is dead.
        */
-      if (deref_var && (deref_var->var->type->is_scalar() ||
-			deref_var->var->type->is_vector())) {
-
-	 if (debug)
-	    printf("looking for %s.0x%01x to remove\n", var->name,
-		   ir->write_mask);
-
-	 foreach_in_list_safe(assignment_entry, entry, assignments) {
-	    if (entry->lhs != var)
-	       continue;
-
-            /* Skip if the assignment we're trying to eliminate isn't a plain
-             * variable deref. */
-            if (entry->ir->lhs->ir_type != ir_type_dereference_variable)
-               continue;
-
-	    int remove = entry->unused & ir->write_mask;
-	    if (debug) {
-	       printf("%s 0x%01x - 0x%01x = 0x%01x\n",
-		      var->name,
-		      entry->ir->write_mask,
-		      remove, entry->ir->write_mask & ~remove);
-	    }
-	    if (remove) {
-	       progress = true;
-
-	       if (debug) {
-		  printf("rewriting:\n  ");
-		  entry->ir->print();
-		  printf("\n");
-	       }
-
-	       entry->ir->write_mask &= ~remove;
-	       entry->unused &= ~remove;
-	       if (entry->ir->write_mask == 0) {
-		  /* Delete the dead assignment. */
-		  entry->ir->remove();
-		  entry->remove();
-	       } else {
-		  void *mem_ctx = ralloc_parent(entry->ir);
-		  /* Reswizzle the RHS arguments according to the new
-		   * write_mask.
-		   */
-		  unsigned components[4];
-		  unsigned channels = 0;
-		  unsigned next = 0;
-
-		  for (int i = 0; i < 4; i++) {
-		     if ((entry->ir->write_mask | remove) & (1 << i)) {
-			if (!(remove & (1 << i)))
-			   components[channels++] = next;
-			next++;
-		     }
-		  }
-
-		  entry->ir->rhs = new(mem_ctx) ir_swizzle(entry->ir->rhs,
-							   components,
-							   channels);
-		  if (debug) {
-		     printf("to:\n  ");
-		     entry->ir->print();
-		     printf("\n");
-		  }
-	       }
-	    }
-	 }
-      } else if (ir->whole_variable_written() != NULL) {
-	 /* We did a whole-variable assignment.  So, any instruction in
-	  * the assignment list with the same LHS is dead.
-	  */
-	 if (debug)
-	    printf("looking for %s to remove\n", var->name);
-	 foreach_in_list_safe(assignment_entry, entry, assignments) {
-	    if (entry->lhs == var) {
-	       if (debug)
-		  printf("removing %s\n", var->name);
-	       entry->ir->remove();
-	       entry->remove();
-	       progress = true;
-	    }
-	 }
+      if (debug)
+         printf("looking for %s to remove\n", var->name);
+      foreach_in_list_safe(assignment_entry, entry, assignments) {
+         if (entry->lhs == var) {
+            if (debug)
+               printf("removing %s\n", var->name);
+            entry->ir->remove();
+            entry->remove();
+            progress = true;
+         }
       }
+   }
 
    /* Add this instruction to the assignment list available to be removed. */
    assignment_entry *entry = new(lin_ctx) assignment_entry(var, ir);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 8291a13d008..7ba7d316062 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3388,12 +3388,12 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
    assert(r.file != PROGRAM_UNDEFINED);
 
    if (ir->rhs->as_expression() &&
-              this->instructions.get_tail() &&
-              ir->rhs == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->ir &&
-              !((glsl_to_tgsi_instruction *)this->instructions.get_tail())->is_64bit_expanded &&
-              type_size(ir->lhs->type) == 1 &&
-              !ir->lhs->type->is_64bit() &&
-              l.writemask == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->dst[0].writemask) {
+       this->instructions.get_tail() &&
+       ir->rhs == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->ir &&
+       !((glsl_to_tgsi_instruction *)this->instructions.get_tail())->is_64bit_expanded &&
+       type_size(ir->lhs->type) == 1 &&
+       !ir->lhs->type->is_64bit() &&
+       l.writemask == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->dst[0].writemask) {
       /* To avoid emitting an extra MOV when assigning an expression to a
        * variable, emit the last instruction of the expression again, but
        * replace the destination register with the target of the assignment.



More information about the mesa-commit mailing list