[Mesa-dev] [PATCH 6/7] ac: handle subgroup intrinsics
Michael Schellenberger Costa
mschellenbergercosta at googlemail.com
Thu Mar 8 19:02:27 UTC 2018
HI Daniel,
Am 08.03.2018 um 18:10 schrieb Daniel Schürmann:
> ---
> src/amd/common/ac_nir_to_llvm.c | 66 +++++++++++++++++++++++------------------
> 1 file changed, 37 insertions(+), 29 deletions(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 9b85069860..0f4cc32f15 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -4363,36 +4363,12 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
> result = ac_build_ballot(&ctx->ac, get_src(ctx, instr->src[0]));
> break;
> case nir_intrinsic_read_invocation:
> - case nir_intrinsic_read_first_invocation: {
> - LLVMValueRef args[2];
> -
> - /* Value */
> - args[0] = get_src(ctx, instr->src[0]);
> -
> - unsigned num_args;
> - const char *intr_name;
> - if (instr->intrinsic == nir_intrinsic_read_invocation) {
> - num_args = 2;
> - intr_name = "llvm.amdgcn.readlane";
> -
> - /* Invocation */
> - args[1] = get_src(ctx, instr->src[1]);
> - } else {
> - num_args = 1;
> - intr_name = "llvm.amdgcn.readfirstlane";
> - }
> -
> - /* We currently have no other way to prevent LLVM from lifting the icmp
> - * calls to a dominating basic block.
> - */
> - ac_build_optimization_barrier(&ctx->ac, &args[0]);
> -
> - result = ac_build_intrinsic(&ctx->ac, intr_name,
> - ctx->ac.i32, args, num_args,
> - AC_FUNC_ATTR_READNONE |
> - AC_FUNC_ATTR_CONVERGENT);
> + result = ac_build_readlane(&ctx->ac, get_src(ctx, instr->src[0]),
> + get_src(ctx, instr->src[1]));
> + break;
> + case nir_intrinsic_read_first_invocation:
> + result = ac_build_readlane(&ctx->ac, get_src(ctx, instr->src[0]), NULL);
> break;
> - }
> case nir_intrinsic_load_subgroup_invocation:
> result = ac_get_thread_id(&ctx->ac);
> break;
> @@ -4646,6 +4622,38 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
> result = LLVMBuildSExt(ctx->ac.builder, tmp, ctx->ac.i32, "");
> break;
> }
> + case nir_intrinsic_shuffle:
> + result = ac_build_shuffle(&ctx->ac, get_src(ctx, instr->src[0]),
> + get_src(ctx, instr->src[1]));
> + break;
> + case nir_intrinsic_reduce:
> + result = ac_build_reduce(&ctx->ac,
> + get_src(ctx, instr->src[0]),
> + instr->const_index[0],
Identation here and below is off. Took me a second look to see
instr->const_index[0] is just the argument.
--Michael
> + instr->const_index[1]);
> + break;
> + case nir_intrinsic_inclusive_scan:
> + result = ac_build_inclusive_scan(&ctx->ac,
> + get_src(ctx, instr->src[0]),
> + instr->const_index[0]);
> + break;
> + case nir_intrinsic_exclusive_scan:
> + result = ac_build_exclusive_scan(&ctx->ac,
> + get_src(ctx, instr->src[0]),
> + instr->const_index[0]);
> + break;
> + case nir_intrinsic_quad_broadcast: {
> + unsigned lane = instr->const_index[0];
> + result = ac_build_quad_swizzle(&ctx->ac, get_src(ctx, instr->src[0]),
> + lane, lane, lane, lane);
> + break;
> + }
> + case nir_intrinsic_quad_swap_horizontal:
> + case nir_intrinsic_quad_swap_vertical:
> + case nir_intrinsic_quad_swap_diagonal:
> + result = ac_build_quad_swap(&ctx->ac, get_src(ctx, instr->src[0]),
> + instr->const_index[0]);
> + break;
> default:
> fprintf(stderr, "Unknown intrinsic: ");
> nir_print_instr(&instr->instr, stderr);
More information about the mesa-dev
mailing list