Mesa (master): nir: add new mediump opcodes f2[ui]mp, i2fmp, u2fmp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Sep 10 23:50:12 UTC 2020
Module: Mesa
Branch: master
Commit: cdd498bbe8884a316c58458f6298d0239ce6c556
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cdd498bbe8884a316c58458f6298d0239ce6c556
Author: Marek Olšák <marek.olsak at amd.com>
Date: Thu Sep 3 23:47:32 2020 -0400
nir: add new mediump opcodes f2[ui]mp, i2fmp, u2fmp
Algebraic optimizations will select them.
Reviewed-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6283>
---
src/amd/llvm/ac_nir_to_llvm.c | 4 ++++
src/compiler/nir/nir_opcodes.py | 4 ++++
src/compiler/nir/nir_opt_algebraic.py | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 2645cfbffcd..d227358322d 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -897,6 +897,7 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
break;
case nir_op_f2i8:
case nir_op_f2i16:
+ case nir_op_f2imp:
case nir_op_f2i32:
case nir_op_f2i64:
src[0] = ac_to_float(&ctx->ac, src[0]);
@@ -904,17 +905,20 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
break;
case nir_op_f2u8:
case nir_op_f2u16:
+ case nir_op_f2ump:
case nir_op_f2u32:
case nir_op_f2u64:
src[0] = ac_to_float(&ctx->ac, src[0]);
result = LLVMBuildFPToUI(ctx->ac.builder, src[0], def_type, "");
break;
case nir_op_i2f16:
+ case nir_op_i2fmp:
case nir_op_i2f32:
case nir_op_i2f64:
result = LLVMBuildSIToFP(ctx->ac.builder, src[0], ac_to_float_type(&ctx->ac, def_type), "");
break;
case nir_op_u2f16:
+ case nir_op_u2fmp:
case nir_op_u2f32:
case nir_op_u2f64:
result = LLVMBuildUIToFP(ctx->ac.builder, src[0], ac_to_float_type(&ctx->ac, def_type), "");
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index 99194af2f13..27b09fa7900 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -275,6 +275,10 @@ for src_t in [tint, tuint, tfloat, tbool]:
unop_numeric_convert("f2fmp", tfloat16, tfloat32, opcodes["f2f16"].const_expr)
unop_numeric_convert("i2imp", tint16, tint32, opcodes["i2i16"].const_expr)
# u2ump isn't defined, because the behavior is equal to i2imp
+unop_numeric_convert("f2imp", tint16, tfloat32, opcodes["f2i16"].const_expr)
+unop_numeric_convert("f2ump", tuint16, tfloat32, opcodes["f2u16"].const_expr)
+unop_numeric_convert("i2fmp", tfloat16, tint32, opcodes["i2f16"].const_expr)
+unop_numeric_convert("u2fmp", tfloat16, tuint32, opcodes["u2f16"].const_expr)
# Unary floating-point rounding operations.
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 3e42f2552e4..663fb365135 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -2068,8 +2068,12 @@ late_optimizations = [
# any conversions that could have been removed will have been removed in
# nir_opt_algebraic so any remaining ones are required.
(('f2fmp', a), ('f2f16', a)),
+ (('f2imp', a), ('f2i16', a)),
+ (('f2ump', a), ('f2u16', a)),
(('i2imp', a), ('i2i16', a)),
+ (('i2fmp', a), ('i2f16', a)),
(('i2imp', a), ('u2u16', a)),
+ (('u2fmp', a), ('u2f16', a)),
# Section 8.8 (Integer Functions) of the GLSL 4.60 spec says:
#
More information about the mesa-commit
mailing list