radeonsi: replace SI.packf16 with amdgcn.cvt.pkrtz
authorMarek Olšák <marek.olsak@amd.com>
Fri, 24 Feb 2017 15:38:25 +0000 (16:38 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 3 Mar 2017 14:29:30 +0000 (15:29 +0100)
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_shader.c

index 187c2cb05e2904b43703fcaa16bce715fdde0b7e..42965b6a544fbc8fe6b7a9cb7e8e40fea1dba467 100644 (file)
@@ -1080,3 +1080,21 @@ LLVMValueRef ac_emit_image_opcode(struct ac_llvm_context *ctx,
                                      AC_FUNC_ATTR_READNONE |
                                      AC_FUNC_ATTR_LEGACY);
 }
+
+LLVMValueRef ac_emit_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
+                                  LLVMValueRef args[2])
+{
+       if (HAVE_LLVM >= 0x0500) {
+               LLVMTypeRef v2f16 =
+                       LLVMVectorType(LLVMHalfTypeInContext(ctx->context), 2);
+               LLVMValueRef res =
+                       ac_emit_llvm_intrinsic(ctx, "llvm.amdgcn.cvt.pkrtz",
+                                              v2f16, args, 2,
+                                              AC_FUNC_ATTR_READNONE);
+               return LLVMBuildBitCast(ctx->builder, res, ctx->i32, "");
+       }
+
+       return ac_emit_llvm_intrinsic(ctx, "llvm.SI.packf16", ctx->i32, args, 2,
+                                     AC_FUNC_ATTR_READNONE |
+                                     AC_FUNC_ATTR_LEGACY);
+}
index f57acc206639d06367f647e03a081ad487401761..e6bb90fd7abafc7adfb878a69bbcfd8944b0425f 100644 (file)
@@ -233,6 +233,8 @@ struct ac_image_args {
 
 LLVMValueRef ac_emit_image_opcode(struct ac_llvm_context *ctx,
                                  struct ac_image_args *a);
+LLVMValueRef ac_emit_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
+                                  LLVMValueRef args[2]);
 
 #ifdef __cplusplus
 }
index 5dc53fcf75098e4250c0b3c3fdb6ae4375125fb5..efb39bf0da33d0070236319e71f2a5194908ad4d 100644 (file)
@@ -1822,11 +1822,7 @@ static void si_llvm_init_export_args(struct lp_build_tgsi_context *bld_base,
                        };
                        LLVMValueRef packed;
 
-                       packed = lp_build_intrinsic(base->gallivm->builder,
-                                                   "llvm.SI.packf16",
-                                                   ctx->i32, pack_args, 2,
-                                                   LP_FUNC_ATTR_READNONE |
-                                                   LP_FUNC_ATTR_LEGACY);
+                       packed = ac_emit_cvt_pkrtz_f16(&ctx->ac, pack_args);
                        args->out[chan] =
                                LLVMBuildBitCast(base->gallivm->builder,
                                                 packed, ctx->f32, "");