I found this in a shader that was doing an alpha test when alpha is fixed
at 1.0.
v2: Rebase on master (now the const value is "u32" not "u").
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (v1)
progress |= constant_fold_deref(&instr->instr, instr->variables[i]);
}
+ if (instr->intrinsic == nir_intrinsic_discard_if) {
+ nir_const_value *src_val = nir_src_as_const_value(instr->src[0]);
+ if (src_val && src_val->u32[0] == 0) {
+ nir_instr_remove(&instr->instr);
+ progress = true;
+ }
+ }
+
return progress;
}