Re-indentation after the previous commit

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
This commit is contained in:
Ian Romanick 2022-01-14 19:12:24 -08:00 committed by Marge Bot
parent 912299cb39
commit 59889eb3ae
4 changed files with 107 additions and 106 deletions

View file

@ -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);
}
/*

View file

@ -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());
}
}
}

View file

@ -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 (deref_var && (deref_var->var->type->is_scalar() ||
deref_var->var->type->is_vector())) {
/* 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);
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;
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;
/* 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;
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");
}
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;
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++;
}
}
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;
}
}
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;
}
}
}
/* Add this instruction to the assignment list available to be removed. */
assignment_entry *entry = new(lin_ctx) assignment_entry(var, ir);

View file

@ -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.