From 99372c1ed7b77049a5e96f32b77550f1c82d0f75 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 29 May 2024 14:56:17 +0200 Subject: [PATCH] nir: add ford, funord, fneo, fequ, fltu, fgeu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Timur Kristóf Reviewed-by: Faith Ekstrand Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir.c | 6 ++++++ src/compiler/nir/nir.h | 6 ++++++ src/compiler/nir/nir_opcodes.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 3bdc706f6c4..3512a8ce3be 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -2905,8 +2905,14 @@ nir_alu_instr_is_comparison(const nir_alu_instr *instr) switch (instr->op) { CASE_ALL_SIZES(nir_op_flt) CASE_ALL_SIZES(nir_op_fge) + CASE_ALL_SIZES(nir_op_fltu) + CASE_ALL_SIZES(nir_op_fgeu) CASE_ALL_SIZES(nir_op_feq) CASE_ALL_SIZES(nir_op_fneu) + CASE_ALL_SIZES(nir_op_fequ) + CASE_ALL_SIZES(nir_op_fneo) + CASE_ALL_SIZES(nir_op_funord) + CASE_ALL_SIZES(nir_op_ford) CASE_ALL_SIZES(nir_op_ilt) CASE_ALL_SIZES(nir_op_ult) CASE_ALL_SIZES(nir_op_ige) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index ed070eb14e0..85ed1c874c0 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4025,6 +4025,12 @@ typedef struct nir_shader_compiler_options { /* Backend supports fused comapre against zero and csel */ bool has_fused_comp_and_csel; + /* Backend supports fneo, fequ, fltu, fgeu. */ + bool has_fneo_fcmpu; + + /* Backend supports ford and funord. */ + bool has_ford_funord; + /** Backend supports fsub, if not set fsub will automatically be lowered to * fadd(x, fneg(y)). If true, driver should call nir_opt_algebraic_late(). */ bool has_fsub; diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 6267fef17fd..9907b8c0ccb 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -823,8 +823,14 @@ binop("frem", tfloat, "", "src0 - src1 * truncf(src0 / src1)") binop_compare_all_sizes("flt", tfloat, "", "src0 < src1") binop_compare_all_sizes("fge", tfloat, "", "src0 >= src1") +binop_compare_all_sizes("fltu", tfloat, "", "isnan(src0) || isnan(src1) || src0 < src1") +binop_compare_all_sizes("fgeu", tfloat, "", "isnan(src0) || isnan(src1) || src0 >= src1") binop_compare_all_sizes("feq", tfloat, _2src_commutative, "src0 == src1") binop_compare_all_sizes("fneu", tfloat, _2src_commutative, "src0 != src1") +binop_compare_all_sizes("fequ", tfloat, _2src_commutative, "isnan(src0) || isnan(src1) || src0 == src1") +binop_compare_all_sizes("fneo", tfloat, _2src_commutative, "!isnan(src0) && !isnan(src1) && src0 != src1") +binop_compare_all_sizes("funord", tfloat, _2src_commutative, "isnan(src0) || isnan(src1)") +binop_compare_all_sizes("ford", tfloat, _2src_commutative, "!isnan(src0) && !isnan(src1)") binop_compare_all_sizes("ilt", tint, "", "src0 < src1") binop_compare_all_sizes("ige", tint, "", "src0 >= src1") binop_compare_all_sizes("ieq", tint, _2src_commutative, "src0 == src1")