ac: add 8-bit and 16-bit supports to ac_build_shuffle()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 8 Nov 2019 11:44:39 +0000 (12:44 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 19 Nov 2019 18:01:13 +0000 (18:01 +0000)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/llvm/ac_llvm_build.c

index 8137713d08609683aba1337c357242dd596ae9df..f2349018dee04b61690b2bdc604950fcb812734f 100644 (file)
@@ -4320,12 +4320,17 @@ ac_build_quad_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src,
 LLVMValueRef
 ac_build_shuffle(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef index)
 {
+       LLVMTypeRef type = LLVMTypeOf(src);
+       LLVMValueRef result;
+
        index = LLVMBuildMul(ctx->builder, index, LLVMConstInt(ctx->i32, 4, 0), "");
-       return ac_build_intrinsic(ctx,
-                 "llvm.amdgcn.ds.bpermute", ctx->i32,
-                 (LLVMValueRef []) {index, src}, 2,
-                 AC_FUNC_ATTR_READNONE |
-                 AC_FUNC_ATTR_CONVERGENT);
+       src = LLVMBuildZExt(ctx->builder, src, ctx->i32, "");
+
+       result = ac_build_intrinsic(ctx, "llvm.amdgcn.ds.bpermute", ctx->i32,
+                                   (LLVMValueRef []) {index, src}, 2,
+                                   AC_FUNC_ATTR_READNONE |
+                                   AC_FUNC_ATTR_CONVERGENT);
+       return LLVMBuildTrunc(ctx->builder, result, type, "");
 }
 
 LLVMValueRef