[Mesa-dev] [PATCH 3/3] r600g: use fcmp and select instructions for TGSI_OPCODE_MAX/MIN
Vincent Lejeune
vljn at ovi.com
Thu Nov 29 12:33:22 PST 2012
---
src/gallium/drivers/r600/r600_llvm.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c
index 2056b91..804a1a9 100644
--- a/src/gallium/drivers/r600/r600_llvm.c
+++ b/src/gallium/drivers/r600/r600_llvm.c
@@ -428,6 +428,28 @@ struct lp_build_emit_data * emit_data)
lp_build_const_float(bld_base->base.gallivm, 1.0f), emit_data->args[0], "");
}
+static void llvm_fmax(
+const struct lp_build_tgsi_action * action,
+struct lp_build_tgsi_context * bld_base,
+struct lp_build_emit_data * emit_data)
+{
+ LLVMBuilderRef builder = bld_base->base.gallivm->builder;
+ emit_data->output[emit_data->chan] = LLVMBuildSelect(builder,
+ LLVMBuildFCmp(builder, LLVMRealUGE, emit_data->args[0], emit_data->args[1], ""),
+ emit_data->args[0], emit_data->args[1], "");
+}
+
+static void llvm_fmin(
+const struct lp_build_tgsi_action * action,
+struct lp_build_tgsi_context * bld_base,
+struct lp_build_emit_data * emit_data)
+{
+ LLVMBuilderRef builder = bld_base->base.gallivm->builder;
+ emit_data->output[emit_data->chan] = LLVMBuildSelect(builder,
+ LLVMBuildFCmp(builder, LLVMRealUGE, emit_data->args[0], emit_data->args[1], ""),
+ emit_data->args[1], emit_data->args[0], "");
+}
+
static struct lp_build_tgsi_action dot_action = {
.fetch_args = dp_fetch_args,
.emit = build_tgsi_intrinsic_nomem,
@@ -473,6 +495,8 @@ LLVMModuleRef r600_tgsi_llvm(
bld_base->op_actions[TGSI_OPCODE_MAD].emit = llvm_fmad;
bld_base->op_actions[TGSI_OPCODE_DIV].emit = llvm_fdiv;
bld_base->op_actions[TGSI_OPCODE_RCP].emit = llvm_frcp;
+ bld_base->op_actions[TGSI_OPCODE_MAX].emit = llvm_fmax;
+ bld_base->op_actions[TGSI_OPCODE_MIN].emit = llvm_fmin;
lp_build_tgsi_llvm(bld_base, tokens);
--
1.8.0
More information about the mesa-dev
mailing list