[Mesa-dev] [PATCH 17/22] glsl: Eliminate ir_assignment constructors that have a condition

Ian Romanick idr at freedesktop.org
Thu Sep 21 14:34:30 UTC 2017


From: "\"Ian Romanick\"" <idr at freedesktop.org>

From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/compiler/glsl/ast_function.cpp        | 15 +++++++--------
 src/compiler/glsl/ir.cpp                  | 19 ++++++-------------
 src/compiler/glsl/ir.h                    |  5 ++---
 src/compiler/glsl/ir_builder.cpp          |  1 -
 src/compiler/glsl/ir_clone.cpp            |  8 ++------
 src/compiler/glsl/ir_reader.cpp           |  3 ++-
 src/compiler/glsl/lower_mat_op_to_vec.cpp |  2 +-
 src/compiler/glsl/lower_vector.cpp        |  4 ++--
 src/compiler/glsl/opt_array_splitting.cpp |  7 +++----
 9 files changed, 25 insertions(+), 39 deletions(-)

diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index 46a61e4..5e3ea5e 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -1134,8 +1134,7 @@ process_vec_mat_constructor(exec_list *instructions,
          assert(var->type->is_vector());
          assert(i < 4);
          ir_dereference *lhs = new(ctx) ir_dereference_variable(var);
-         assignment = new(ctx) ir_assignment(lhs, rhs, NULL,
-                                             (unsigned)(1 << i));
+         assignment = new(ctx) ir_assignment(lhs, rhs, 1U << i);
       }
 
       instructions->push_tail(assignment);
@@ -1332,7 +1331,7 @@ emit_inline_vector_constructor(const glsl_type *type,
 
       assert(rhs->type == lhs->type);
 
-      ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, mask);
+      ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, mask);
       instructions->push_tail(inst);
    } else {
       unsigned base_component = 0;
@@ -1402,7 +1401,7 @@ emit_inline_vector_constructor(const glsl_type *type,
          ir_rvalue *rhs = new(ctx) ir_constant(rhs_type, &data);
 
          ir_instruction *inst =
-            new(ctx) ir_assignment(lhs, rhs, NULL, constant_mask);
+            new(ctx) ir_assignment(lhs, rhs, constant_mask);
          instructions->push_tail(inst);
       }
 
@@ -1436,7 +1435,7 @@ emit_inline_vector_constructor(const glsl_type *type,
                new(ctx) ir_swizzle(param, 0, 1, 2, 3, rhs_components);
 
             ir_instruction *inst =
-               new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
+               new(ctx) ir_assignment(lhs, rhs, write_mask);
             instructions->push_tail(inst);
          }
 
@@ -1487,7 +1486,7 @@ assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base,
    /* Mask of fields to be written in the assignment. */
    const unsigned write_mask = ((1U << count) - 1) << row_base;
 
-   return new(mem_ctx) ir_assignment(column_ref, src, NULL, write_mask);
+   return new(mem_ctx) ir_assignment(column_ref, src, write_mask);
 }
 
 
@@ -1555,7 +1554,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
       ir_dereference *const rhs_ref =
          new(ctx) ir_dereference_variable(rhs_var);
 
-      inst = new(ctx) ir_assignment(rhs_ref, first_param, NULL, 0x01);
+      inst = new(ctx) ir_assignment(rhs_ref, first_param, 0x01);
       instructions->push_tail(inst);
 
       /* Assign the temporary vector to each column of the destination matrix
@@ -1704,7 +1703,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
          }
 
          ir_instruction *inst =
-            new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
+            new(ctx) ir_assignment(lhs, rhs, write_mask);
          instructions->push_tail(inst);
       }
    } else {
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 49db56e..4cf322d 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -149,14 +149,10 @@ ir_assignment::whole_variable_written()
 }
 
 ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
-			     ir_rvalue *condition, unsigned write_mask)
-   : ir_instruction(ir_type_assignment)
+                             unsigned write_mask)
+   : ir_instruction(ir_type_assignment), lhs(lhs), rhs(rhs),
+     condition(NULL), write_mask(write_mask)
 {
-   this->condition = condition;
-   this->rhs = rhs;
-   this->lhs = lhs;
-   this->write_mask = write_mask;
-
    if (lhs->type->is_scalar() || lhs->type->is_vector()) {
       int lhs_components = 0;
       for (int i = 0; i < 4; i++) {
@@ -168,13 +164,10 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
    }
 }
 
-ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
-			     ir_rvalue *condition)
-   : ir_instruction(ir_type_assignment)
+ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs)
+   : ir_instruction(ir_type_assignment), lhs(NULL), rhs(rhs),
+     condition(NULL), write_mask(0)
 {
-   this->condition = condition;
-   this->rhs = rhs;
-
    /* If the RHS is a vector type, assume that all components of the vector
     * type are being written to the LHS.  The write mask comes from the RHS
     * because we can have a case where the LHS is a vec4 and the RHS is a
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 27eafe8..28a356a 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -1419,7 +1419,7 @@ public:
 
 class ir_assignment : public ir_instruction {
 public:
-   ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition = NULL);
+   ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs);
 
    /**
     * Construct an assignment with an explicit write mask
@@ -1428,8 +1428,7 @@ public:
     * Since a write mask is supplied, the LHS must already be a bare
     * \c ir_dereference.  The cannot be any swizzles in the LHS.
     */
-   ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, ir_rvalue *condition,
-		 unsigned write_mask);
+   ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, unsigned write_mask);
 
    virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const;
 
diff --git a/src/compiler/glsl/ir_builder.cpp b/src/compiler/glsl/ir_builder.cpp
index fd9881b..7a713ff 100644
--- a/src/compiler/glsl/ir_builder.cpp
+++ b/src/compiler/glsl/ir_builder.cpp
@@ -52,7 +52,6 @@ assign(deref lhs, operand rhs, int writemask)
 
    ir_assignment *assign = new(mem_ctx) ir_assignment(lhs.val,
                                                       rhs.val,
-                                                      NULL,
                                                       writemask);
 
    return assign;
diff --git a/src/compiler/glsl/ir_clone.cpp b/src/compiler/glsl/ir_clone.cpp
index 1213507..4cea988 100644
--- a/src/compiler/glsl/ir_clone.cpp
+++ b/src/compiler/glsl/ir_clone.cpp
@@ -251,15 +251,11 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const
 ir_assignment *
 ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const
 {
-   ir_rvalue *new_condition = NULL;
-
-   if (this->condition)
-      new_condition = this->condition->clone(mem_ctx, ht);
+   assert(this->condition == NULL);
 
    ir_assignment *cloned =
       new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht),
-                                 this->rhs->clone(mem_ctx, ht),
-                                 new_condition);
+                                 this->rhs->clone(mem_ctx, ht));
    cloned->write_mask = this->write_mask;
    return cloned;
 }
diff --git a/src/compiler/glsl/ir_reader.cpp b/src/compiler/glsl/ir_reader.cpp
index b87933b..fd00620 100644
--- a/src/compiler/glsl/ir_reader.cpp
+++ b/src/compiler/glsl/ir_reader.cpp
@@ -641,7 +641,8 @@ ir_reader::read_assignment(s_expression *expr)
       return NULL;
    }
 
-   return new(mem_ctx) ir_assignment(lhs, rhs, condition, mask);
+   assert(condition == NULL);
+   return new(mem_ctx) ir_assignment(lhs, rhs, mask);
 }
 
 ir_call *
diff --git a/src/compiler/glsl/lower_mat_op_to_vec.cpp b/src/compiler/glsl/lower_mat_op_to_vec.cpp
index 88c5d66..70fad18 100644
--- a/src/compiler/glsl/lower_mat_op_to_vec.cpp
+++ b/src/compiler/glsl/lower_mat_op_to_vec.cpp
@@ -271,7 +271,7 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result,
 	 new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
 
       ir_assignment *const assign =
-	 new(this->mem_ctx) ir_assignment(lhs, cmp, NULL, (1U << i));
+	 new(this->mem_ctx) ir_assignment(lhs, cmp, (1U << i));
 
       this->base_ir->insert_before(assign);
    }
diff --git a/src/compiler/glsl/lower_vector.cpp b/src/compiler/glsl/lower_vector.cpp
index 4024644..d1535e4 100644
--- a/src/compiler/glsl/lower_vector.cpp
+++ b/src/compiler/glsl/lower_vector.cpp
@@ -191,7 +191,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
 				  &d);
       ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
       ir_assignment *const assign =
-	 new(mem_ctx) ir_assignment(lhs, c, NULL, write_mask);
+         new(mem_ctx) ir_assignment(lhs, c, write_mask);
 
       this->base_ir->insert_before(assign);
    }
@@ -204,7 +204,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
 
       ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
       ir_assignment *const assign =
-	 new(mem_ctx) ir_assignment(lhs, expr->operands[i], NULL, (1U << i));
+         new(mem_ctx) ir_assignment(lhs, expr->operands[i], (1U << i));
 
       this->base_ir->insert_before(assign);
       assigned++;
diff --git a/src/compiler/glsl/opt_array_splitting.cpp b/src/compiler/glsl/opt_array_splitting.cpp
index 7d928b9..110fccb 100644
--- a/src/compiler/glsl/opt_array_splitting.cpp
+++ b/src/compiler/glsl/opt_array_splitting.cpp
@@ -415,11 +415,10 @@ ir_array_splitting_visitor::visit_leave(ir_assignment *ir)
          ir_rvalue *rhs_i =
             new(mem_ctx) ir_dereference_array(ir->rhs->clone(mem_ctx, NULL),
                                               new(mem_ctx) ir_constant(i));
-         ir_rvalue *condition_i =
-            ir->condition ? ir->condition->clone(mem_ctx, NULL) : NULL;
 
-         ir_assignment *assign_i =
-            new(mem_ctx) ir_assignment(lhs_i, rhs_i, condition_i);
+         assert(ir->condition == NULL);
+
+         ir_assignment *assign_i = new(mem_ctx) ir_assignment(lhs_i, rhs_i);
 
          ir->insert_before(assign_i);
          assign_i->accept(this);
-- 
2.9.5



More information about the mesa-dev mailing list