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

Author: Emma Anholt <[email protected]>
Date:   Wed Dec 29 16:50:06 2021 -0800

nir/opt_offsets: Disable unsigned wrap checks on non-native-integers HW.

Since we don't have 32-bit ints, these checks for 32-bit unsigned wrapping
don't help and just reduce optimization opportunities (particularly for
DX9 addressing math).

Doesn't affect any current consumers.

Reviewed-by: Timur Kristóf <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14309>

---

 src/compiler/nir/nir_opt_offsets.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_offsets.c 
b/src/compiler/nir/nir_opt_offsets.c
index 0d10fc93e46..d833f0448a2 100644
--- a/src/compiler/nir/nir_opt_offsets.c
+++ b/src/compiler/nir/nir_opt_offsets.c
@@ -46,7 +46,12 @@ try_extract_const_addition(nir_builder *b, nir_instr *instr, 
opt_offsets_state *
        !nir_alu_src_is_trivial_ssa(alu, 1))
       return NULL;
 
-   if (!alu->no_unsigned_wrap) {
+   /* Make sure that we aren't taking out an addition that could trigger
+    * unsigned wrapping in a way that would change the semantics of the load.
+    * Ignored for ints-as-floats (lower_bitops is a proxy for that), where
+    * unsigned wrapping doesn't make sense.
+    */
+   if (!alu->no_unsigned_wrap && !b->shader->options->lower_bitops) {
       if (!state->range_ht) {
          /* Cache for nir_unsigned_upper_bound */
          state->range_ht = _mesa_pointer_hash_table_create(NULL);

Reply via email to