glsl: Use _mesa_bitcount to implement constant ir_unop_bit_count
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 11 Jul 2016 18:20:02 +0000 (11:20 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 30 Aug 2016 23:28:00 +0000 (16:28 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/compiler/glsl/ir_constant_expression.cpp

index 2664fefbc45b582f2c62135f8b5908dfe894a6de..01a7224f47003ed5246482c5525cf756a5e1c0b7 100644 (file)
@@ -1500,15 +1500,8 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
       break;
 
    case ir_unop_bit_count:
-      for (unsigned c = 0; c < components; c++) {
-         unsigned count = 0;
-         unsigned v = op[0]->value.u[c];
-
-         for (; v; count++) {
-            v &= v - 1;
-         }
-         data.u[c] = count;
-      }
+      for (unsigned c = 0; c < components; c++)
+         data.i[c] = _mesa_bitcount(op[0]->value.u[c]);
       break;
 
    case ir_unop_find_msb: