This could be squashed with the previous commit. I kept it separate to
ease review.
v2: Use a switch statement and add more comments. Both suggested by
Caio.
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
break;
case nir_op_fsat:
- r = (struct ssa_result_range){ge_zero, analyze_expression(alu, 0, ht).is_integral};
+ r = analyze_expression(alu, 0, ht);
+
+ switch (r.range) {
+ case le_zero:
+ case lt_zero:
+ r.range = eq_zero;
+ r.is_integral = true;
+ break;
+
+ case eq_zero:
+ assert(r.is_integral);
+ case gt_zero:
+ case ge_zero:
+ /* The fsat doesn't add any information in these cases. */
+ break;
+
+ case ne_zero:
+ case unknown:
+ /* Since the result must be in [0, 1], the value must be >= 0. */
+ r.range = ge_zero;
+ break;
+ }
break;
case nir_op_fsign: