[Mesa-dev] [PATCH] nir: remove the abs call in is_neg_power_of_two

Vlad Golovkin vlad.golovkin.mail at gmail.com
Tue Feb 6 03:16:08 UTC 2018


val->i32[swizzle[i]] is guaranteed to have non-positive value before the
__is_power_of_two call, so unary minus is equivalent to abs in this case.
---
 src/compiler/nir/nir_search_helpers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h
index 2e3bd137d6..66e1546ae6 100644
--- a/src/compiler/nir/nir_search_helpers.h
+++ b/src/compiler/nir/nir_search_helpers.h
@@ -80,7 +80,7 @@ is_neg_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components,
       case nir_type_int:
          if (val->i32[swizzle[i]] > 0)
             return false;
-         if (!__is_power_of_two(abs(val->i32[swizzle[i]])))
+         if (!__is_power_of_two(-val->i32[swizzle[i]]))
             return false;
          break;
       default:
-- 
2.14.1



More information about the mesa-dev mailing list