glsl: Don't pass NULL to ir_assignment constructor when not necessary
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 18 Sep 2017 20:30:51 +0000 (15:30 -0500)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 2 Oct 2017 21:46:02 +0000 (14:46 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
src/compiler/glsl/ast_function.cpp
src/compiler/glsl/ir_expression_flattening.cpp
src/compiler/glsl/lower_discard.cpp
src/compiler/glsl/lower_instructions.cpp
src/compiler/glsl/lower_jumps.cpp
src/compiler/glsl/lower_texture_projection.cpp
src/compiler/glsl/opt_function_inlining.cpp
src/compiler/glsl/opt_structure_splitting.cpp

index d528eccf313ff9bcf0b0e788be18391832f175fd..46a61e46fd5b0290f66f428869215002a97d5810 100644 (file)
@@ -1128,7 +1128,7 @@ process_vec_mat_constructor(exec_list *instructions,
       if (var->type->is_matrix()) {
          ir_rvalue *lhs =
             new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i));
-         assignment = new(ctx) ir_assignment(lhs, rhs, NULL);
+         assignment = new(ctx) ir_assignment(lhs, rhs);
       } else {
          /* use writemask rather than index for vector */
          assert(var->type->is_vector());
@@ -1264,7 +1264,7 @@ process_array_constructor(exec_list *instructions,
       ir_rvalue *lhs = new(ctx) ir_dereference_array(var,
                                                      new(ctx) ir_constant(i));
 
-      ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs, NULL);
+      ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs);
       instructions->push_tail(assignment);
 
       i++;
@@ -1549,8 +1549,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
 
       ir_instruction *inst =
          new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var),
-                                new(ctx) ir_constant(rhs_var->type, &zero),
-                                NULL);
+                                new(ctx) ir_constant(rhs_var->type, &zero));
       instructions->push_tail(inst);
 
       ir_dereference *const rhs_ref =
@@ -1583,7 +1582,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
          ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i],
                                                     type->vector_elements);
 
-         inst = new(ctx) ir_assignment(col_ref, rhs, NULL);
+         inst = new(ctx) ir_assignment(col_ref, rhs);
          instructions->push_tail(inst);
       }
 
@@ -1596,7 +1595,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
          ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1,
                                                     type->vector_elements);
 
-         inst = new(ctx) ir_assignment(col_ref, rhs, NULL);
+         inst = new(ctx) ir_assignment(col_ref, rhs);
          instructions->push_tail(inst);
       }
    } else if (first_param->type->is_matrix()) {
@@ -1650,7 +1649,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
             ir_rvalue *const lhs =
                new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col));
 
-            ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL);
+            ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs);
             instructions->push_tail(inst);
          }
       }
@@ -1668,7 +1667,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
       ir_dereference *const rhs_var_ref =
          new(ctx) ir_dereference_variable(rhs_var);
       ir_instruction *const inst =
-         new(ctx) ir_assignment(rhs_var_ref, first_param, NULL);
+         new(ctx) ir_assignment(rhs_var_ref, first_param);
       instructions->push_tail(inst);
 
       const unsigned last_row = MIN2(src_matrix->type->vector_elements,
@@ -1731,7 +1730,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
 
          ir_dereference *rhs_var_ref =
             new(ctx) ir_dereference_variable(rhs_var);
-         ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, NULL);
+         ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs);
          instructions->push_tail(inst);
 
          do {
@@ -1795,8 +1794,7 @@ emit_inline_record_constructor(const glsl_type *type,
       ir_rvalue *const rhs = ((ir_instruction *) node)->as_rvalue();
       assert(rhs != NULL);
 
-      ir_instruction *const assign =
-         new(mem_ctx) ir_assignment(lhs, rhs, NULL);
+      ir_instruction *const assign = new(mem_ctx) ir_assignment(lhs, rhs);
 
       instructions->push_tail(assign);
       node = node->next;
@@ -2158,7 +2156,7 @@ ast_function_expression::hir(exec_list *instructions,
             instructions->push_tail(var);
             instructions->push_tail(
                new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
-                                      matrix, NULL));
+                                      matrix));
             var->constant_value = matrix->constant_expression_value(ctx);
 
             /* Replace the matrix with dereferences of its columns. */
index c13ae811d78b1dfdccbf0a2ccc25f0acbf7df765..e4ca850d2f488661021a83bc3bb9f62f077f9437 100644 (file)
@@ -77,9 +77,7 @@ ir_expression_flattening_visitor::handle_rvalue(ir_rvalue **rvalue)
    var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary);
    base_ir->insert_before(var);
 
-   assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
-                                  ir,
-                                  NULL);
+   assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), ir);
    base_ir->insert_before(assign);
 
    *rvalue = new(ctx) ir_dereference_variable(var);
index b62eb20dcb49159a5905d5afb6105b7a5bfae54d..203d9e3b96038074ed3296356c1b7e799119d52d 100644 (file)
@@ -158,7 +158,7 @@ replace_discard(void *mem_ctx, ir_variable *var, ir_discard *ir)
 
    ir_assignment *assignment =
       new(mem_ctx) ir_assignment(new(mem_ctx) ir_dereference_variable(var),
-                                condition, NULL);
+                                 condition);
 
    ir->replace_with(assignment);
 }
@@ -180,7 +180,7 @@ lower_discard_visitor::visit_leave(ir_if *ir)
                                                ir_var_temporary);
    ir_assignment *temp_initializer =
       new(mem_ctx) ir_assignment(new(mem_ctx) ir_dereference_variable(temp),
-                                new(mem_ctx) ir_constant(false), NULL);
+                                 new(mem_ctx) ir_constant(false));
 
    ir->insert_before(temp);
    ir->insert_before(temp_initializer);
index 362562a4af64c5d76e7d5ee5c0d2ea09332f9db0..91f71b37619af38c11a43e32c53ab19fd5673f1a 100644 (file)
@@ -319,10 +319,10 @@ lower_instructions_visitor::mod_to_floor(ir_expression *ir)
 
    ir_assignment *const assign_x =
       new(ir) ir_assignment(new(ir) ir_dereference_variable(x),
-                            ir->operands[0], NULL);
+                            ir->operands[0]);
    ir_assignment *const assign_y =
       new(ir) ir_assignment(new(ir) ir_dereference_variable(y),
-                            ir->operands[1], NULL);
+                            ir->operands[1]);
 
    this->base_ir->insert_before(assign_x);
    this->base_ir->insert_before(assign_y);
index 7dc34056a1b1dc14d00684cb8a8952fe90fba616..3286a1c57945824b4628e99350ed9782205d4908 100644 (file)
@@ -189,7 +189,7 @@ struct loop_record
       if(!this->execute_flag) {
          exec_list& list = this->loop ? this->loop->body_instructions : signature->body;
          this->execute_flag = new(this->signature) ir_variable(glsl_type::bool_type, "execute_flag", ir_var_temporary);
-         list.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(execute_flag), new(this->signature) ir_constant(true), 0));
+         list.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(execute_flag), new(this->signature) ir_constant(true)));
          list.push_head(this->execute_flag);
       }
       return this->execute_flag;
@@ -201,7 +201,7 @@ struct loop_record
       if(!this->break_flag) {
          this->break_flag = new(this->signature) ir_variable(glsl_type::bool_type, "break_flag", ir_var_temporary);
          this->loop->insert_before(this->break_flag);
-         this->loop->insert_before(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(break_flag), new(this->signature) ir_constant(false), 0));
+         this->loop->insert_before(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(break_flag), new(this->signature) ir_constant(false)));
       }
       return this->break_flag;
    }
@@ -229,7 +229,7 @@ struct function_record
    {
       if(!this->return_flag) {
          this->return_flag = new(this->signature) ir_variable(glsl_type::bool_type, "return_flag", ir_var_temporary);
-         this->signature->body.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(return_flag), new(this->signature) ir_constant(false), 0));
+         this->signature->body.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(return_flag), new(this->signature) ir_constant(false)));
          this->signature->body.push_head(this->return_flag);
       }
       return this->return_flag;
@@ -356,8 +356,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor {
       void *ctx = this->function.signature;
       return new(ctx) ir_assignment(
           new(ctx) ir_dereference_variable(this->loop.get_break_flag()),
-          new(ctx) ir_constant(true),
-          0);
+          new(ctx) ir_constant(true));
    }
 
    /**
@@ -681,7 +680,7 @@ lower_continue:
              * this->loop must be initialized even outside of loops.
              */
             ir_variable* execute_flag = this->loop.get_execute_flag();
-            jumps[lower]->replace_with(new(ir) ir_assignment(new (ir) ir_dereference_variable(execute_flag), new (ir) ir_constant(false), 0));
+            jumps[lower]->replace_with(new(ir) ir_assignment(new (ir) ir_dereference_variable(execute_flag), new (ir) ir_constant(false)));
             /* Note: we must update block_records and jumps to reflect
              * the fact that the control path has been altered to an
              * instruction that clears the execute flag.
index 698e5b36617321de2ad98b2c6695e1038640dd0e..db847f8a8c3d62595323f4b5c48bbba312cbabda 100644 (file)
@@ -69,7 +69,7 @@ lower_texture_projection_visitor::visit_leave(ir_texture *ir)
                                                    ir->projector->type,
                                                    ir->projector,
                                                    NULL);
-   ir_assignment *assign = new(mem_ctx) ir_assignment(deref, expr, NULL);
+   ir_assignment *assign = new(mem_ctx) ir_assignment(deref, expr);
    base_ir->insert_before(assign);
 
    deref = new(mem_ctx) ir_dereference_variable(var);
index 78a726b2cc9649c3c909be00d68df21aeca69e8f..04690b6cf45367f33a256d5e44d54cfab49fcaa0 100644 (file)
@@ -89,7 +89,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data)
    if (ret) {
       if (ret->value) {
         ir_rvalue *lhs = orig_deref->clone(ctx, NULL);
-        ret->replace_with(new(ctx) ir_assignment(lhs, ret->value, NULL));
+         ret->replace_with(new(ctx) ir_assignment(lhs, ret->value));
       } else {
         /* un-valued return has to be the last return, or we shouldn't
          * have reached here. (see can_inline()).
@@ -121,7 +121,7 @@ ir_save_lvalue_visitor::visit_enter(ir_dereference_array *deref)
       base_ir->insert_before(index);
 
       assignment = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(index),
-                                          deref->array_index, 0);
+                                          deref->array_index);
       base_ir->insert_before(assignment);
 
       deref->array_index = new(ctx) ir_dereference_variable(index);
@@ -199,7 +199,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
             ir_assignment *assign;
 
             assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
-                                            param, NULL);
+                                            param);
             next_ir->insert_before(assign);
          } else {
             assert(sig_param->data.mode == ir_var_function_out ||
@@ -215,7 +215,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
                ir_assignment *assign;
 
                assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
-                                               param->clone(ctx, NULL)->as_rvalue(), NULL);
+                                               param->clone(ctx, NULL)->as_rvalue());
                next_ir->insert_before(assign);
             }
          }
@@ -268,8 +268,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
         ir_assignment *assign;
 
          assign = new(ctx) ir_assignment(param,
-                                        new(ctx) ir_dereference_variable(parameters[i]),
-                                        NULL);
+                                         new(ctx) ir_dereference_variable(parameters[i]));
         next_ir->insert_before(assign);
       }
 
index a015d6d7c935b1755475458236bf2d2d858d4d2c..f7562df39c8646db62ad90154cf011edc6493fb0 100644 (file)
@@ -285,9 +285,7 @@ ir_structure_splitting_visitor::visit_leave(ir_assignment *ir)
                                     type->fields.structure[i].name);
         }
 
-        ir->insert_before(new(mem_ctx) ir_assignment(new_lhs,
-                                                     new_rhs,
-                                                     NULL));
+         ir->insert_before(new(mem_ctx) ir_assignment(new_lhs, new_rhs));
       }
       ir->remove();
    } else {