Mesa (main): nir: Add unsigned upper bound for extract opcodes.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 30 14:26:55 UTC 2021


Module: Mesa
Branch: main
Commit: a25fd1787a8004ae3ef29b08f2f848103c68c370
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a25fd1787a8004ae3ef29b08f2f848103c68c370

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Thu Aug 26 11:18:23 2021 +0200

nir: Add unsigned upper bound for extract opcodes.

This helps with some cases of extract, such as:
- Emitting more optimal integer multiplications
- Better address calculation
- Possibly others

Fossil DB results on Sienna Cichlid:

Totals from 4064 (3.16% of 128647) affected shaders:
VGPRs: 262040 -> 262032 (-0.00%)
CodeSize: 28856648 -> 28811892 (-0.16%); split: -0.18%, +0.02%
Instrs: 5370279 -> 5367827 (-0.05%); split: -0.08%, +0.04%
Latency: 74230112 -> 74016671 (-0.29%); split: -0.29%, +0.01%
InvThroughput: 12082532 -> 12036365 (-0.38%); split: -0.39%, +0.01%
VClause: 108506 -> 108721 (+0.20%); split: -0.03%, +0.22%
SClause: 217731 -> 216602 (-0.52%); split: -0.67%, +0.15%
Copies: 265689 -> 270811 (+1.93%); split: -0.26%, +2.19%
PreSGPRs: 201982 -> 204907 (+1.45%); split: -0.01%, +1.46%
PreVGPRs: 236099 -> 236079 (-0.01%)

Fossil DB results on Sienna Cichlid with NGGC enabled:

Totals from 60375 (46.93% of 128647) affected shaders:
VGPRs: 2212576 -> 2212568 (-0.00%)
CodeSize: 180870420 -> 179684816 (-0.66%); split: -0.66%, +0.00%
Instrs: 34386715 -> 34213682 (-0.50%); split: -0.51%, +0.01%
Latency: 199676290 -> 198987998 (-0.34%); split: -0.35%, +0.00%
InvThroughput: 32288299 -> 31736433 (-1.71%); split: -1.71%, +0.00%
VClause: 621521 -> 621743 (+0.04%); split: -0.00%, +0.04%
SClause: 900447 -> 899392 (-0.12%); split: -0.16%, +0.04%
Copies: 3439529 -> 3445305 (+0.17%); split: -0.02%, +0.19%
PreSGPRs: 2216297 -> 2219220 (+0.13%); split: -0.00%, +0.13%
PreVGPRs: 1842887 -> 1842867 (-0.00%)

Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12558>

---

 src/compiler/nir/nir_range_analysis.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c
index 4e37881526f..f45f6db2fd7 100644
--- a/src/compiler/nir/nir_range_analysis.c
+++ b/src/compiler/nir/nir_range_analysis.c
@@ -1459,6 +1459,10 @@ nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht,
       case nir_op_bfm:
       case nir_op_f2u32:
       case nir_op_fmul:
+      case nir_op_extract_u8:
+      case nir_op_extract_i8:
+      case nir_op_extract_u16:
+      case nir_op_extract_i16:
          break;
       case nir_op_u2u1:
       case nir_op_u2u8:
@@ -1591,6 +1595,18 @@ nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht,
       case nir_op_sad_u8x4:
          res = src2 + 4 * 255;
          break;
+      case nir_op_extract_u8:
+         res = MIN2(src0, UINT8_MAX);
+         break;
+      case nir_op_extract_i8:
+         res = (src0 >= 0x80) ? max : MIN2(src0, INT8_MAX);
+         break;
+      case nir_op_extract_u16:
+         res = MIN2(src0, UINT16_MAX);
+         break;
+      case nir_op_extract_i16:
+         res = (src0 >= 0x8000) ? max : MIN2(src0, INT16_MAX);
+         break;
       default:
          res = max;
          break;



More information about the mesa-commit mailing list