diff options
author | Ian Romanick <[email protected]> | 2018-06-01 18:54:49 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2019-08-05 20:14:13 -0700 |
commit | 3009cbed5053150fbee351ee7b9f61d3aaf6794b (patch) | |
tree | 277a1f061cb0518cff618a12c80d89c97e9e5810 | |
parent | 405de7ccb6cb0b2e38a861e9ddbb535598718734 (diff) |
nir/range-analysis: Tighten the range of fsat based on the range of its source
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 <[email protected]>
-rw-r--r-- | src/compiler/nir/nir_range_analysis.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index 8df3558df7a..dac40ecb066 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -553,7 +553,28 @@ analyze_expression(const nir_alu_instr *instr, unsigned src, 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: |