gallivm: add 16-bit split/merge support.

Fixes piglit load-hi16.cl, load-lo16.cl

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7309>
This commit is contained in:
Dave Airlie 2020-10-08 13:44:47 +10:00
parent 4ecdc5ec4e
commit 0f78ca9d54
2 changed files with 63 additions and 7 deletions

View file

@ -127,7 +127,6 @@ program/execute/builtin/builtin-short-mul_hi-1.0.generated/mul_hi short2: fail
program/execute/builtin/builtin-short-mul_hi-1.0.generated/mul_hi short4: fail
program/execute/builtin/builtin-short-mul_hi-1.0.generated/mul_hi short8: fail
program/execute/builtin/builtin-short-popcount-1.2.generated: skip
program/execute/builtin/builtin-short-upsample-1.0.generated: crash
program/execute/builtin/builtin-shuffle-half-ushort: skip
program/execute/builtin/builtin-shuffle2-half-ushort: skip
program/execute/builtin/builtin-uchar-mad_hi-1.0.generated/mad_hi uchar1: fail
@ -165,7 +164,6 @@ program/execute/builtin/builtin-ushort-mul_hi-1.0.generated/mul_hi ushort2: fail
program/execute/builtin/builtin-ushort-mul_hi-1.0.generated/mul_hi ushort4: fail
program/execute/builtin/builtin-ushort-mul_hi-1.0.generated/mul_hi ushort8: fail
program/execute/builtin/builtin-ushort-popcount-1.2.generated: skip
program/execute/builtin/builtin-ushort-upsample-1.0.generated: crash
program/execute/call-clobbers-amdgcn: skip
program/execute/calls-large-struct: crash
program/execute/calls-struct/regs struct: fail
@ -176,9 +174,7 @@ program/execute/image-read-2d/read float from cl_float cl_rgba image.: fail
program/execute/image-read-2d/read signed integer from cl_signed_int8 cl_rgba image.: fail
program/execute/image-read-2d/read unsigned integer from cl_unsigned_int8 cl_rgba image.: fail
program/execute/image-write-2d: crash
program/execute/load-hi16: crash
program/execute/load-hi16-generic: skip
program/execute/load-lo16: crash
program/execute/load-lo16-generic: skip
program/execute/mad-mix: skip
program/execute/program-tester-check-local-size-test-should-skip/this test should skip: skip
@ -197,9 +193,9 @@ program/execute/vstore/vstore-half-private: skip
summary:
name: results
---- --------
pass: 3627
pass: 3654
fail: 107
crash: 12
crash: 8
skip: 73
timeout: 4
warn: 0
@ -209,4 +205,4 @@ summary:
changes: 0
fixes: 0
regressions: 0
total: 3823
total: 3846

View file

@ -398,6 +398,55 @@ merge_64bit(struct lp_build_nir_context *bld_base,
return LLVMBuildShuffleVector(builder, input, input2, LLVMConstVector(shuffles, len), "");
}
static LLVMValueRef split_16bit(struct lp_build_nir_context *bld_base,
LLVMValueRef src,
bool hi)
{
struct gallivm_state *gallivm = bld_base->base.gallivm;
LLVMValueRef shuffles[LP_MAX_VECTOR_WIDTH/32];
LLVMValueRef shuffles2[LP_MAX_VECTOR_WIDTH/32];
int len = bld_base->base.type.length * 2;
for (unsigned i = 0; i < bld_base->base.type.length; i++) {
#if UTIL_ARCH_LITTLE_ENDIAN
shuffles[i] = lp_build_const_int32(gallivm, i * 2);
shuffles2[i] = lp_build_const_int32(gallivm, (i * 2) + 1);
#else
shuffles[i] = lp_build_const_int32(gallivm, (i * 2) + 1);
shuffles2[i] = lp_build_const_int32(gallivm, (i * 2));
#endif
}
src = LLVMBuildBitCast(gallivm->builder, src, LLVMVectorType(LLVMInt16TypeInContext(gallivm->context), len), "");
return LLVMBuildShuffleVector(gallivm->builder, src,
LLVMGetUndef(LLVMTypeOf(src)),
LLVMConstVector(hi ? shuffles2 : shuffles,
bld_base->base.type.length),
"");
}
static LLVMValueRef
merge_16bit(struct lp_build_nir_context *bld_base,
LLVMValueRef input,
LLVMValueRef input2)
{
struct gallivm_state *gallivm = bld_base->base.gallivm;
LLVMBuilderRef builder = gallivm->builder;
int i;
LLVMValueRef shuffles[2 * (LP_MAX_VECTOR_WIDTH/32)];
int len = bld_base->int16_bld.type.length * 2;
assert(len <= (2 * (LP_MAX_VECTOR_WIDTH/32)));
for (i = 0; i < bld_base->int_bld.type.length * 2; i+=2) {
#if UTIL_ARCH_LITTLE_ENDIAN
shuffles[i] = lp_build_const_int32(gallivm, i / 2);
shuffles[i + 1] = lp_build_const_int32(gallivm, i / 2 + bld_base->base.type.length);
#else
shuffles[i] = lp_build_const_int32(gallivm, i / 2 + bld_base->base.type.length);
shuffles[i + 1] = lp_build_const_int32(gallivm, i / 2);
#endif
}
return LLVMBuildShuffleVector(builder, input, input2, LLVMConstVector(shuffles, len), "");
}
static LLVMValueRef
do_int_divide(struct lp_build_nir_context *bld_base,
bool is_unsigned, unsigned src_bit_size,
@ -773,6 +822,17 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
result = split_64bit(bld_base, src[0], true);
break;
case nir_op_pack_32_2x16_split: {
LLVMValueRef tmp = merge_16bit(bld_base, src[0], src[1]);
result = LLVMBuildBitCast(builder, tmp, bld_base->base.vec_type, "");
break;
}
case nir_op_unpack_32_2x16_split_x:
result = split_16bit(bld_base, src[0], false);
break;
case nir_op_unpack_32_2x16_split_y:
result = split_16bit(bld_base, src[0], true);
break;
case nir_op_pack_64_2x32_split: {
LLVMValueRef tmp = merge_64bit(bld_base, src[0], src[1]);
result = LLVMBuildBitCast(builder, tmp, bld_base->dbl_bld.vec_type, "");