Mesa (master): nir/search: fix the PoT helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 18 22:34:58 UTC 2019


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Wed Sep 25 11:59:49 2019 -0700

nir/search: fix the PoT helpers

Otherwise, if the base type is (for example) uint32, we would
incorrectly think that PoT optimizations could not apply.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Jason Ekstsrand <jason at jleksrand.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Reviewed-by: Eduardo Lima Mitev <elima at igalia.com>

---

 src/compiler/nir/nir.h                | 2 +-
 src/compiler/nir/nir_search_helpers.h | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 43c904913d6..cb572ce05ee 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -212,7 +212,7 @@ nir_const_value_as_int(nir_const_value value, unsigned bit_size)
    }
 }
 
-static inline int64_t
+static inline uint64_t
 nir_const_value_as_uint(nir_const_value value, unsigned bit_size)
 {
    switch (bit_size) {
diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h
index 90ba897742d..4849aef052d 100644
--- a/src/compiler/nir/nir_search_helpers.h
+++ b/src/compiler/nir/nir_search_helpers.h
@@ -42,7 +42,8 @@ is_pos_power_of_two(UNUSED struct hash_table *ht, nir_alu_instr *instr,
       return false;
 
    for (unsigned i = 0; i < num_components; i++) {
-      switch (nir_op_infos[instr->op].input_types[src]) {
+      nir_alu_type type = nir_op_infos[instr->op].input_types[src];
+      switch (nir_alu_type_get_base_type(type)) {
       case nir_type_int: {
          int64_t val = nir_src_comp_as_int(instr->src[src].src, swizzle[i]);
          if (val <= 0 || !util_is_power_of_two_or_zero64(val))
@@ -73,7 +74,8 @@ is_neg_power_of_two(UNUSED struct hash_table *ht, nir_alu_instr *instr,
       return false;
 
    for (unsigned i = 0; i < num_components; i++) {
-      switch (nir_op_infos[instr->op].input_types[src]) {
+      nir_alu_type type = nir_op_infos[instr->op].input_types[src];
+      switch (nir_alu_type_get_base_type(type)) {
       case nir_type_int: {
          int64_t val = nir_src_comp_as_int(instr->src[src].src, swizzle[i]);
          if (val >= 0 || !util_is_power_of_two_or_zero64(-val))
@@ -153,7 +155,8 @@ is_not_const_zero(UNUSED struct hash_table *ht, nir_alu_instr *instr,
       return true;
 
    for (unsigned i = 0; i < num_components; i++) {
-      switch (nir_op_infos[instr->op].input_types[src]) {
+      nir_alu_type type = nir_op_infos[instr->op].input_types[src];
+      switch (nir_alu_type_get_base_type(type)) {
       case nir_type_float:
          if (nir_src_comp_as_float(instr->src[src].src, swizzle[i]) == 0.0)
             return false;




More information about the mesa-commit mailing list