[Mesa-dev] [PATCH 1/2] gallivm: have a default emit function for fdiv/rcp

Tom Stellard tom at stellard.net
Fri Nov 30 08:20:24 PST 2012


On Thu, Nov 29, 2012 at 11:50:22PM +0100, Vincent Lejeune wrote:
> ---
>  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 24 ++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> index 17f288f..ff21879 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> @@ -584,6 +584,28 @@ mul_emit(
>                                     emit_data->args[0], emit_data->args[1]);
>  }
>  
> +/*.TGSI_OPCODE_DIV.*/
> +static void fdiv_emit(
> +   const struct lp_build_tgsi_action * action,
> +   struct lp_build_tgsi_context * bld_base,
> +   struct lp_build_emit_data * emit_data)
> +{
> +   emit_data->output[emit_data->chan] = lp_build_div(&bld_base->base,
> +                                   emit_data->args[0], emit_data->args[1]);

I don't like using the lp_build_* helpers for default operations, because
they can sometimes produce SSE intrinsics.  I think we should use LLVMBuildFDiv
here.

> +}
> +
> +/*.TGSI_OPCODE_RCP.*/
> +static void rcp_emit(
> +   const struct lp_build_tgsi_action * action,
> +   struct lp_build_tgsi_context * bld_base,
> +   struct lp_build_emit_data * emit_data)
> +{
> +   LLVMValueRef one;
> +   one = lp_build_const_float(bld_base->base.gallivm, 1.0f);
> +   emit_data->output[emit_data->chan] = lp_build_div(&bld_base->base,
> +                                   one, emit_data->args[0]);

Instead of lp_build_div, we should use lp_build_emit_llvm_binary() with
TGSI_OPCODE_DIV.

> +}
> +
>  /* TGSI_OPCODE_POW */
>  
>  static void
> @@ -811,6 +833,8 @@ lp_set_default_actions(struct lp_build_tgsi_context * bld_base)
>     bld_base->op_actions[TGSI_OPCODE_MAD].emit = mad_emit;
>     bld_base->op_actions[TGSI_OPCODE_MOV].emit = mov_emit;
>     bld_base->op_actions[TGSI_OPCODE_MUL].emit = mul_emit;
> +   bld_base->op_actions[TGSI_OPCODE_DIV].emit = fdiv_emit;
> +   bld_base->op_actions[TGSI_OPCODE_RCP].emit = rcp_emit;
>     bld_base->op_actions[TGSI_OPCODE_SFL].emit = sfl_emit;
>     bld_base->op_actions[TGSI_OPCODE_STR].emit = str_emit;
>     bld_base->op_actions[TGSI_OPCODE_SUB].emit = sub_emit;
> -- 
> 1.8.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list