glsl: Add ir_unop_f2fmp
authorNeil Roberts <nroberts@igalia.com>
Wed, 9 Oct 2019 11:07:40 +0000 (13:07 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 9 Mar 2020 16:31:08 +0000 (16:31 +0000)
This is the same as ir_unop_f2f16 except that it comes with a promise
that it is safe to optimise it out if the result is immediately
converted back to float32 again. Normally this would be a lossy
operation but it is safe to do if the conversion was generated as part
of the precision lowering pass.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>

src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/ir.cpp
src/compiler/glsl/ir_expression_operation.py
src/compiler/glsl/ir_validate.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 6d82fca..d8fbc80 100644 (file)
@@ -2079,6 +2079,11 @@ nir_visitor::visit(ir_expression *ir)
       break;
    }
 
+   case ir_unop_f2fmp: {
+      result = nir_build_alu(&b, nir_op_f2fmp, srcs[0], NULL, NULL, NULL);
+      break;
+   }
+
    case ir_unop_bitcast_i2f:
    case ir_unop_bitcast_f2i:
    case ir_unop_bitcast_u2f:
index 4df511f..4d4bc0f 100644 (file)
@@ -293,6 +293,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
       break;
 
    case ir_unop_f2f16:
+   case ir_unop_f2fmp:
    case ir_unop_b2f16:
       this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16,
                                           op0->type->vector_elements, 1);
index 48fbc87..5fcc9ee 100644 (file)
@@ -459,6 +459,7 @@ ir_expression_operation = [
    # still have to handle them here so that we can constant propagate through
    # them, but they are no-ops.
    operation("f2f16", 1, source_types=(float_type,), dest_type=float_type, c_expression="{src0}"),
+   operation("f2fmp", 1, source_types=(float_type,), dest_type=float_type, c_expression="{src0}"),
    operation("f162f", 1, source_types=(float_type,), dest_type=float_type, c_expression="{src0}"),
    # Double-to-integer conversion.
    operation("d2i", 1, source_types=(double_type,), dest_type=int_type, c_expression="{src0}"),
index 02a5f3d..4c4948c 100644 (file)
@@ -593,6 +593,7 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->type->is_float());
       break;
    case ir_unop_f2f16:
+   case ir_unop_f2fmp:
       assert(ir->operands[0]->type->is_float());
       assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
       break;
index ee7741b..adb8720 100644 (file)
@@ -1349,6 +1349,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
    case ir_unop_clz:
    case ir_unop_f162f:
    case ir_unop_f2f16:
+   case ir_unop_f2fmp:
    case ir_unop_f162b:
    case ir_unop_b2f16:
       assert(!"not supported");
index e53bed9..31ffa24 100644 (file)
@@ -2397,6 +2397,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
    case ir_binop_mul_32x16:
    case ir_unop_f162f:
    case ir_unop_f2f16:
+   case ir_unop_f2fmp:
    case ir_unop_f162b:
    case ir_unop_b2f16:
       /* This operation is not supported, or should have already been handled.