glsl: Eliminate ir_assignment::condition
Reformatting is left for the next commit. v2: Remove assignments from the contructors. :face_palm: Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
This commit is contained in:
@@ -1718,15 +1718,9 @@ nir_visitor::visit(ir_assignment *ir)
|
||||
nir_deref_instr *rhs = evaluate_deref(ir->rhs);
|
||||
enum gl_access_qualifier lhs_qualifiers = deref_get_qualifier(lhs);
|
||||
enum gl_access_qualifier rhs_qualifiers = deref_get_qualifier(rhs);
|
||||
if (ir->get_condition()) {
|
||||
nir_push_if(&b, evaluate_rvalue(ir->get_condition()));
|
||||
nir_copy_deref_with_access(&b, lhs, rhs, lhs_qualifiers,
|
||||
rhs_qualifiers);
|
||||
nir_pop_if(&b, NULL);
|
||||
} else {
|
||||
nir_copy_deref_with_access(&b, lhs, rhs, lhs_qualifiers,
|
||||
rhs_qualifiers);
|
||||
}
|
||||
|
||||
nir_copy_deref_with_access(&b, lhs, rhs, lhs_qualifiers,
|
||||
rhs_qualifiers);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1763,15 +1757,8 @@ nir_visitor::visit(ir_assignment *ir)
|
||||
}
|
||||
|
||||
enum gl_access_qualifier qualifiers = deref_get_qualifier(lhs_deref);
|
||||
if (ir->get_condition()) {
|
||||
nir_push_if(&b, evaluate_rvalue(ir->get_condition()));
|
||||
nir_store_deref_with_access(&b, lhs_deref, src, write_mask,
|
||||
qualifiers);
|
||||
nir_pop_if(&b, NULL);
|
||||
} else {
|
||||
nir_store_deref_with_access(&b, lhs_deref, src, write_mask,
|
||||
qualifiers);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -153,7 +153,6 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
|
||||
unsigned write_mask)
|
||||
: ir_instruction(ir_type_assignment)
|
||||
{
|
||||
this->unused_condition = NULL;
|
||||
this->rhs = rhs;
|
||||
this->lhs = lhs;
|
||||
this->write_mask = write_mask;
|
||||
@@ -165,7 +164,6 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
|
||||
ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs)
|
||||
: ir_instruction(ir_type_assignment)
|
||||
{
|
||||
this->unused_condition = NULL;
|
||||
this->rhs = rhs;
|
||||
|
||||
/* If the RHS is a vector type, assume that all components of the vector
|
||||
|
@@ -1518,23 +1518,6 @@ public:
|
||||
*/
|
||||
ir_rvalue *rhs;
|
||||
|
||||
/**
|
||||
* Optional condition for the assignment.
|
||||
*/
|
||||
private:
|
||||
ir_rvalue *unused_condition;
|
||||
|
||||
public:
|
||||
inline ir_rvalue *get_condition()
|
||||
{
|
||||
return unused_condition;
|
||||
}
|
||||
|
||||
inline const ir_rvalue *get_condition() const
|
||||
{
|
||||
return unused_condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Component mask written
|
||||
*
|
||||
|
@@ -507,8 +507,6 @@ ir_builder_print_visitor::visit_enter(ir_assignment *ir)
|
||||
if (s != visit_continue)
|
||||
return (s == visit_continue_with_parent) ? visit_continue : s;
|
||||
|
||||
assert(ir->get_condition() == NULL);
|
||||
|
||||
const struct hash_entry *const he_lhs =
|
||||
_mesa_hash_table_search(index_map, ir->lhs);
|
||||
|
||||
@@ -529,7 +527,6 @@ ir_builder_print_visitor::visit_leave(ir_assignment *ir)
|
||||
const struct hash_entry *const he_rhs =
|
||||
_mesa_hash_table_search(index_map, ir->rhs);
|
||||
|
||||
assert(ir->get_condition() == NULL);
|
||||
assert(ir->lhs && ir->rhs);
|
||||
|
||||
print_with_indent("body.emit(assign(r%04X, r%04X, 0x%02x));\n\n",
|
||||
|
@@ -259,8 +259,6 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const
|
||||
ir_assignment *
|
||||
ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const
|
||||
{
|
||||
assert(this->get_condition() == NULL);
|
||||
|
||||
return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht),
|
||||
this->rhs->clone(mem_ctx, ht),
|
||||
this->write_mask);
|
||||
|
@@ -1070,16 +1070,6 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(void *m
|
||||
/* (assign [condition] (write-mask) (ref) (value)) */
|
||||
case ir_type_assignment: {
|
||||
ir_assignment *asg = inst->as_assignment();
|
||||
if (asg->get_condition()) {
|
||||
ir_constant *cond =
|
||||
asg->get_condition()->constant_expression_value(mem_ctx,
|
||||
variable_context);
|
||||
if (!cond)
|
||||
return false;
|
||||
if (!cond->get_bool_component(0))
|
||||
break;
|
||||
}
|
||||
|
||||
ir_constant *store = NULL;
|
||||
int offset = 0;
|
||||
|
||||
|
@@ -312,9 +312,6 @@ ir_assignment::accept(ir_hierarchical_visitor *v)
|
||||
if (s != visit_continue)
|
||||
return (s == visit_continue_with_parent) ? visit_continue : s;
|
||||
|
||||
if (this->get_condition())
|
||||
s = this->get_condition()->accept(v);
|
||||
|
||||
return (s == visit_stop) ? s : v->visit_leave(this);
|
||||
}
|
||||
|
||||
|
@@ -444,9 +444,6 @@ void ir_print_visitor::visit(ir_assignment *ir)
|
||||
{
|
||||
fprintf(f, "(assign ");
|
||||
|
||||
if (ir->get_condition())
|
||||
ir->get_condition()->accept(this);
|
||||
|
||||
char mask[5];
|
||||
unsigned j = 0;
|
||||
|
||||
|
@@ -71,7 +71,7 @@ find_initial_value(ir_loop *loop, ir_variable *var)
|
||||
ir_variable *assignee = assign->lhs->whole_variable_referenced();
|
||||
|
||||
if (assignee == var)
|
||||
return (assign->get_condition() != NULL) ? NULL : assign->rhs;
|
||||
return assign->rhs;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -241,7 +241,6 @@ incremented_before_terminator(ir_loop *loop, ir_variable *var,
|
||||
ir_variable *assignee = assign->lhs->whole_variable_referenced();
|
||||
|
||||
if (assignee == var) {
|
||||
assert(assign->get_condition() == NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -275,8 +274,7 @@ loop_variable::record_reference(bool in_assignee,
|
||||
if (in_assignee) {
|
||||
assert(current_assignment != NULL);
|
||||
|
||||
if (in_conditional_code_or_nested_loop ||
|
||||
current_assignment->get_condition() != NULL) {
|
||||
if (in_conditional_code_or_nested_loop) {
|
||||
this->conditional_or_nested_assignment = true;
|
||||
}
|
||||
|
||||
|
@@ -193,7 +193,6 @@ move_block_to_cond_assign(void *mem_ctx,
|
||||
_mesa_set_search(
|
||||
set, assign->lhs->variable_referenced()) != NULL;
|
||||
|
||||
if (!assign->get_condition()) {
|
||||
if (assign_to_cv) {
|
||||
assign->rhs =
|
||||
new(mem_ctx) ir_expression(ir_binop_logic_and,
|
||||
@@ -207,13 +206,6 @@ move_block_to_cond_assign(void *mem_ctx,
|
||||
assign->rhs,
|
||||
assign->lhs->as_dereference());
|
||||
}
|
||||
} else {
|
||||
assign->rhs =
|
||||
new(mem_ctx) ir_expression(ir_triop_csel,
|
||||
cond_expr->clone(mem_ctx, NULL),
|
||||
assign->rhs,
|
||||
assign->lhs->as_dereference());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -381,22 +381,7 @@ public:
|
||||
|
||||
switch_generator sg(ag, index);
|
||||
|
||||
/* If the original assignment has a condition, respect that original
|
||||
* condition! This is acomplished by wrapping the new conditional
|
||||
* assignments in an if-statement that uses the original condition.
|
||||
*/
|
||||
if (orig_assign != NULL && orig_assign->get_condition() != NULL) {
|
||||
/* No need to clone the condition because the IR that it hangs on is
|
||||
* going to be removed from the instruction sequence.
|
||||
*/
|
||||
ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->get_condition());
|
||||
ir_factory then_body(&if_stmt->then_instructions, body.mem_ctx);
|
||||
|
||||
sg.generate(0, length, then_body);
|
||||
body.emit(if_stmt);
|
||||
} else {
|
||||
sg.generate(0, length, body);
|
||||
}
|
||||
sg.generate(0, length, body);
|
||||
|
||||
base_ir->insert_before(&list);
|
||||
return var;
|
||||
|
@@ -416,8 +416,6 @@ ir_array_splitting_visitor::visit_leave(ir_assignment *ir)
|
||||
new(mem_ctx) ir_dereference_array(ir->rhs->clone(mem_ctx, NULL),
|
||||
new(mem_ctx) ir_constant(i));
|
||||
|
||||
assert(ir->get_condition() == NULL);
|
||||
|
||||
ir_assignment *assign_i = new(mem_ctx) ir_assignment(lhs_i, rhs_i);
|
||||
|
||||
ir->insert_before(assign_i);
|
||||
|
@@ -486,9 +486,6 @@ ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
|
||||
{
|
||||
acp_entry *entry;
|
||||
|
||||
if (ir->get_condition())
|
||||
return;
|
||||
|
||||
if (!ir->write_mask)
|
||||
return;
|
||||
|
||||
|
@@ -116,12 +116,6 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
|
||||
if (entry->var->constant_value)
|
||||
return visit_continue;
|
||||
|
||||
/* OK, now find if we actually have all the right conditions for
|
||||
* this to be a constant value assigned to the var.
|
||||
*/
|
||||
if (ir->get_condition())
|
||||
return visit_continue;
|
||||
|
||||
ir_variable *var = ir->whole_variable_written();
|
||||
if (!var)
|
||||
return visit_continue;
|
||||
|
@@ -654,9 +654,6 @@ ir_copy_propagation_elements_visitor::kill(kill_entry *k)
|
||||
void
|
||||
ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir)
|
||||
{
|
||||
if (ir->get_condition())
|
||||
return;
|
||||
|
||||
{
|
||||
ir_variable *lhs_var = ir->whole_variable_written();
|
||||
ir_dereference_variable *rhs = ir->rhs->as_dereference_variable();
|
||||
|
@@ -175,7 +175,6 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
|
||||
bool progress = false;
|
||||
kill_for_derefs_visitor v(assignments);
|
||||
|
||||
if (ir->get_condition() == NULL) {
|
||||
/* If this is an assignment of the form "foo = foo;", remove the whole
|
||||
* instruction and be done with it.
|
||||
*/
|
||||
@@ -184,13 +183,9 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
|
||||
ir->remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Kill assignment entries for things used to produce this assignment. */
|
||||
ir->rhs->accept(&v);
|
||||
if (ir->get_condition()) {
|
||||
ir->get_condition()->accept(&v);
|
||||
}
|
||||
|
||||
/* Kill assignment enties used as array indices.
|
||||
*/
|
||||
@@ -199,7 +194,6 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
|
||||
assert(var);
|
||||
|
||||
/* Now, check if we did a whole-variable assignment. */
|
||||
if (!ir->get_condition()) {
|
||||
ir_dereference_variable *deref_var = ir->lhs->as_dereference_variable();
|
||||
|
||||
/* If it's a vector type, we can do per-channel elimination of
|
||||
@@ -287,7 +281,6 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add this instruction to the assignment list available to be removed. */
|
||||
assignment_entry *entry = new(lin_ctx) assignment_entry(var, ir);
|
||||
|
@@ -160,8 +160,7 @@ ir_structure_reference_visitor::visit_enter(ir_assignment *ir)
|
||||
return visit_continue_with_parent;
|
||||
|
||||
if (ir->lhs->as_dereference_variable() &&
|
||||
ir->rhs->as_dereference_variable() &&
|
||||
!ir->get_condition()) {
|
||||
ir->rhs->as_dereference_variable()) {
|
||||
/* We'll split copies of a structure to copies of components, so don't
|
||||
* descend to the ir_dereference_variables.
|
||||
*/
|
||||
@@ -264,7 +263,7 @@ ir_structure_splitting_visitor::visit_leave(ir_assignment *ir)
|
||||
variable_entry *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL;
|
||||
const glsl_type *type = ir->rhs->type;
|
||||
|
||||
if ((lhs_entry || rhs_entry) && !ir->get_condition()) {
|
||||
if (lhs_entry || rhs_entry) {
|
||||
for (unsigned int i = 0; i < type->length; i++) {
|
||||
ir_dereference *new_lhs, *new_rhs;
|
||||
void *mem_ctx = lhs_entry ? lhs_entry->mem_ctx : rhs_entry->mem_ctx;
|
||||
|
@@ -3387,12 +3387,7 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
|
||||
assert(l.file != PROGRAM_UNDEFINED);
|
||||
assert(r.file != PROGRAM_UNDEFINED);
|
||||
|
||||
if (ir->get_condition()) {
|
||||
const bool switch_order = this->process_move_condition(ir->get_condition());
|
||||
st_src_reg condition = this->result;
|
||||
|
||||
emit_block_mov(ir, ir->lhs->type, &l, &r, &condition, switch_order);
|
||||
} else if (ir->rhs->as_expression() &&
|
||||
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 &&
|
||||
|
Reference in New Issue
Block a user