This removes the ALU-only restriction on the "weak" GVN introduced by
the previous commit. This makes it slightly more aggressive, allowing
it to coalesce things like UBO loads (still within sister then/else
blocks). This also can have surprisingly large cascading effects.
I was concerned that this might increase register pressure, but
shader-db and fossil-db show effectively no change in spills/fills,
so it seems to be fine.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19823>
}
/**
- * Are ALU instructions a and b both contained in the same if/else block?
+ * Are instructions a and b both contained in the same if/else block?
*/
static bool
weak_gvn(const nir_instr *a, const nir_instr *b)
{
- if (a->type != nir_instr_type_alu)
- return false;
-
const struct nir_cf_node *ap = a->block->cf_node.parent;
const struct nir_cf_node *bp = b->block->cf_node.parent;
return ap && ap == bp && ap->type == nir_cf_node_if;