From 6d1765c63aed1b814b29051c702f8e79ead6dbed Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 18 Sep 2017 15:30:51 -0500 Subject: [PATCH] glsl: Don't pass NULL to ir_assignment constructor when not necessary MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Ian Romanick Reviewed-by: Alejandro Piñeiro --- src/compiler/glsl/ast_function.cpp | 22 +++++++++---------- .../glsl/ir_expression_flattening.cpp | 4 +--- src/compiler/glsl/lower_discard.cpp | 4 ++-- src/compiler/glsl/lower_instructions.cpp | 4 ++-- src/compiler/glsl/lower_jumps.cpp | 11 +++++----- .../glsl/lower_texture_projection.cpp | 2 +- src/compiler/glsl/opt_function_inlining.cpp | 11 +++++----- src/compiler/glsl/opt_structure_splitting.cpp | 4 +--- 8 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index d528eccf313..46a61e46fd5 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -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. */ diff --git a/src/compiler/glsl/ir_expression_flattening.cpp b/src/compiler/glsl/ir_expression_flattening.cpp index c13ae811d78..e4ca850d2f4 100644 --- a/src/compiler/glsl/ir_expression_flattening.cpp +++ b/src/compiler/glsl/ir_expression_flattening.cpp @@ -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); diff --git a/src/compiler/glsl/lower_discard.cpp b/src/compiler/glsl/lower_discard.cpp index b62eb20dcb4..203d9e3b960 100644 --- a/src/compiler/glsl/lower_discard.cpp +++ b/src/compiler/glsl/lower_discard.cpp @@ -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); diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index 362562a4af6..91f71b37619 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -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); diff --git a/src/compiler/glsl/lower_jumps.cpp b/src/compiler/glsl/lower_jumps.cpp index 7dc34056a1b..3286a1c5794 100644 --- a/src/compiler/glsl/lower_jumps.cpp +++ b/src/compiler/glsl/lower_jumps.cpp @@ -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. diff --git a/src/compiler/glsl/lower_texture_projection.cpp b/src/compiler/glsl/lower_texture_projection.cpp index 698e5b36617..db847f8a8c3 100644 --- a/src/compiler/glsl/lower_texture_projection.cpp +++ b/src/compiler/glsl/lower_texture_projection.cpp @@ -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); diff --git a/src/compiler/glsl/opt_function_inlining.cpp b/src/compiler/glsl/opt_function_inlining.cpp index 78a726b2cc9..04690b6cf45 100644 --- a/src/compiler/glsl/opt_function_inlining.cpp +++ b/src/compiler/glsl/opt_function_inlining.cpp @@ -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); } diff --git a/src/compiler/glsl/opt_structure_splitting.cpp b/src/compiler/glsl/opt_structure_splitting.cpp index a015d6d7c93..f7562df39c8 100644 --- a/src/compiler/glsl/opt_structure_splitting.cpp +++ b/src/compiler/glsl/opt_structure_splitting.cpp @@ -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 { -- 2.30.2