glsl: Move 'foo = foo;' optimization to opt_dead_code_local

The optimization as done in opt_copy_propagation would have to be
removed in the next patch.  If we just eliminate that optimization
altogether, shader-db results, even on platforms that use NIR, are hurt
quite substantially.  I have not investigated why NIR isn't picking up
the slack here.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Cc: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Ian Romanick
2017-09-20 19:51:39 -05:00
parent 623002f0b2
commit ff5254bf08
2 changed files with 18 additions and 12 deletions
+11
View File
@@ -173,6 +173,17 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
bool progress = false;
kill_for_derefs_visitor v(assignments);
if (ir->condition == NULL) {
/* 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);
if (ir->condition) {