[Mesa-dev] [PATCH 2/3] r600g: use fdiv instruction for TGSI_OPCODE_DIV/RCP
Vincent Lejeune
vljn at ovi.com
Thu Nov 29 12:32:08 PST 2012
---
src/gallium/drivers/r600/r600_llvm.c | 22 ++++++++++++++++++++++
.../drivers/radeon/radeon_setup_tgsi_llvm.c | 4 ++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c
index 350527b..2056b91 100644
--- a/src/gallium/drivers/r600/r600_llvm.c
+++ b/src/gallium/drivers/r600/r600_llvm.c
@@ -408,6 +408,26 @@ static void llvm_fmad(
emit_data->args[2], "");
}
+static void llvm_fdiv(
+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] = LLVMBuildFDiv(builder,
+ emit_data->args[0], emit_data->args[1], "");
+}
+
+static void llvm_frcp(
+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] = LLVMBuildFDiv(builder,
+ lp_build_const_float(bld_base->base.gallivm, 1.0f), emit_data->args[0], "");
+}
+
static struct lp_build_tgsi_action dot_action = {
.fetch_args = dp_fetch_args,
.emit = build_tgsi_intrinsic_nomem,
@@ -451,6 +471,8 @@ LLVMModuleRef r600_tgsi_llvm(
bld_base->op_actions[TGSI_OPCODE_CMP].emit = emit_cndlt;
bld_base->op_actions[TGSI_OPCODE_MUL].emit = llvm_fmul;
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;
lp_build_tgsi_llvm(bld_base, tokens);
diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index cbcebbc..93d3009 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -540,8 +540,8 @@ static void emit_prepare_cube_coords(
coords[2] = build_intrinsic(builder, "fabs",
type, &coords[2], 1, LLVMReadNoneAttribute);
- coords[2] = build_intrinsic(builder, "llvm.AMDGPU.rcp",
- type, &coords[2], 1, LLVMReadNoneAttribute);
+ coords[2] = LLVMBuildFDiv(builder, lp_build_const_float(gallivm, 1.0f),
+ coords[2], "");
mad_args[1] = coords[2];
mad_args[2] = LLVMConstReal(type, 1.5);
--
1.8.0
More information about the mesa-dev
mailing list