Mesa (master): ac: add 8-bit and 16-bit supports to get_reduction_identity()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 19 18:01:47 UTC 2019
Module: Mesa
Branch: master
Commit: ef352a2466d620e7605502d6f404b17d4bf5ddd5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef352a2466d620e7605502d6f404b17d4bf5ddd5
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Fri Nov 8 16:35:45 2019 +0100
ac: add 8-bit and 16-bit supports to get_reduction_identity()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
src/amd/llvm/ac_llvm_build.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index 241cbba2dc8..641587051b8 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -3904,7 +3904,39 @@ ac_build_set_inactive(struct ac_llvm_context *ctx, LLVMValueRef src,
static LLVMValueRef
get_reduction_identity(struct ac_llvm_context *ctx, nir_op op, unsigned type_size)
{
- if (type_size == 4) {
+ if (type_size == 1) {
+ switch (op) {
+ case nir_op_iadd: return ctx->i8_0;
+ case nir_op_imul: return ctx->i8_1;
+ case nir_op_imin: return LLVMConstInt(ctx->i8, INT8_MAX, 0);
+ case nir_op_umin: return LLVMConstInt(ctx->i8, UINT8_MAX, 0);
+ case nir_op_imax: return LLVMConstInt(ctx->i8, INT8_MIN, 0);
+ case nir_op_umax: return ctx->i8_0;
+ case nir_op_iand: return LLVMConstInt(ctx->i8, -1, 0);
+ case nir_op_ior: return ctx->i8_0;
+ case nir_op_ixor: return ctx->i8_0;
+ default:
+ unreachable("bad reduction intrinsic");
+ }
+ } else if (type_size == 2) {
+ switch (op) {
+ case nir_op_iadd: return ctx->i16_0;
+ case nir_op_fadd: return ctx->f16_0;
+ case nir_op_imul: return ctx->i16_1;
+ case nir_op_fmul: return ctx->f16_1;
+ case nir_op_imin: return LLVMConstInt(ctx->i16, INT16_MAX, 0);
+ case nir_op_umin: return LLVMConstInt(ctx->i16, UINT16_MAX, 0);
+ case nir_op_fmin: return LLVMConstReal(ctx->f16, INFINITY);
+ case nir_op_imax: return LLVMConstInt(ctx->i16, INT16_MIN, 0);
+ case nir_op_umax: return ctx->i16_0;
+ case nir_op_fmax: return LLVMConstReal(ctx->f16, -INFINITY);
+ case nir_op_iand: return LLVMConstInt(ctx->i16, -1, 0);
+ case nir_op_ior: return ctx->i16_0;
+ case nir_op_ixor: return ctx->i16_0;
+ default:
+ unreachable("bad reduction intrinsic");
+ }
+ } else if (type_size == 4) {
switch (op) {
case nir_op_iadd: return ctx->i32_0;
case nir_op_fadd: return ctx->f32_0;
More information about the mesa-commit
mailing list