[Mesa-dev] [PATCH 32/50] glsl: Add a lowering pass for 64-bit integer modulus

Ian Romanick idr at freedesktop.org
Tue Nov 29 03:25:47 UTC 2016


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/compiler/glsl/ir_optimization.h |  1 +
 src/compiler/glsl/lower_64bit.cpp   | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 3f0ef7d..d46b957 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -54,6 +54,7 @@
 #define MUL64                     (1U << 0)
 #define SIGN64                    (1U << 1)
 #define DIV64                     (1U << 2)
+#define MOD64                     (1U << 3)
 
 /**
  * \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 1bd55c9..0128730 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -379,6 +379,17 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_binop_mod:
+      if (lowering(MOD64)) {
+         if (ir->type->base_type == GLSL_TYPE_UINT64) {
+            *rvalue = handle_op(ir, "__builtin_umod64", generate_ir::umod64);
+         } else {
+            *rvalue = handle_op(ir, "__builtin_imod64", generate_ir::imod64);
+         }
+         this->progress = true;
+      }
+      break;
+
    case ir_binop_mul:
       if (lowering(MUL64)) {
          *rvalue = handle_op(ir, "__builtin_umul64", generate_ir::umul64);
-- 
2.7.4



More information about the mesa-dev mailing list