[Mesa-dev] [PATCH 38/50] glsl/lower_64bit: lower d2b using comparison

Dave Airlie airlied at gmail.com
Tue Mar 13 04:25:03 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This just does a compare to 0 and inverts the result to lower
d2b. Not 100% sure this is always correct, but it passes piglit
---
 src/compiler/glsl/lower_64bit.cpp | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 794cc3e..c4b8e78 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -349,7 +349,7 @@ lower_64bit::lower_op_to_function_call(ir_instruction *base_ir,
                                        ir_expression *ir,
                                        ir_function_signature *callee)
 {
-   const unsigned num_operands = ir->num_operands;
+   unsigned num_operands = ir->num_operands;
    ir_variable *src[4][4];
    ir_variable *dst[4];
    void *const mem_ctx = ralloc_parent(ir);
@@ -378,6 +378,16 @@ lower_64bit::lower_op_to_function_call(ir_instruction *base_ir,
          source_components = ir->operands[i]->type->vector_elements;
    }
 
+   if (ir->operation == ir_unop_d2b) {
+      for (unsigned i = 0; i < source_components; i++) {
+         src[1][i] = body.make_temp(glsl_type::uvec2_type, "zero");
+
+         body.emit(assign(src[1][i], body.constant(0u), 1));
+         body.emit(assign(src[1][i], body.constant(0u), 2));
+      }
+      num_operands++;
+   }
+
    for (unsigned i = 0; i < source_components; i++) {
       dst[i] = body.make_temp(result_type, "expanded_64bit_result");
 
@@ -394,6 +404,9 @@ lower_64bit::lower_op_to_function_call(ir_instruction *base_ir,
                                               &parameters);
 
       body.emit(c);
+
+      if (ir->operation == ir_unop_d2b)
+         body.emit(assign(dst[i], logic_not(dst[i])));
    }
 
    ir_rvalue *rv;
@@ -475,6 +488,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_unop_d2b:
+      if (lowering(EQ64)) {
+         if (ir->type->base_type == GLSL_TYPE_BOOL)
+            *rvalue = handle_op(ir, "__builtin_feq64", generate_ir::feq64);
+      }
+      break;
+
    case ir_unop_d2f:
       if (lowering(D2F)) {
          if (ir->type->base_type == GLSL_TYPE_FLOAT)
-- 
2.9.5



More information about the mesa-dev mailing list