NIR: intel: Enhancements to nir_opt_peephole_select
Generally, this makes the bcsel
peephole optimization a little more greedy. The first patch causes the pass to not include things that are expected to become source or destination modifiers in the instructions. This causes more if-statement to be converted.
Later patches try to clean up some of the odd patterns that may result from lowering if-statements to a series of bcsel
. The latter was not as successful as I would have liked.
I think we may want to either modify this pass or add a separate pass to do some code motion like this. I see a lot of shaders that do things like:
if (condition) {
// some math
coord = ...;
x = texture(s, coord);
} else {
// some different math
coord = ...;
x = texture(s, coord);
}
If the condition is non-uniform, this is not ideal. A pass like this could move the texture access out of the if-statement.