ac: use llvm.amdgcn.writelane
authorMarek Olšák <marek.olsak@amd.com>
Tue, 16 Jul 2019 05:07:49 +0000 (01:07 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 20 Jul 2019 00:16:19 +0000 (20:16 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_llvm_build.c

index 221850139b19e23bfd1af1e60f3f055472bc517c..041b6cd797eb4c3c70e4d1a3ea9b0d1c9cd5bf06 100644 (file)
@@ -3825,8 +3825,12 @@ ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef la
 LLVMValueRef
 ac_build_writelane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef value, LLVMValueRef lane)
 {
-       /* TODO: Use the actual instruction when LLVM adds an intrinsic for it.
-        */
+       if (HAVE_LLVM >= 0x0800) {
+               return ac_build_intrinsic(ctx, "llvm.amdgcn.writelane", ctx->i32,
+                                         (LLVMValueRef []) {value, lane, src}, 3,
+                                         AC_FUNC_ATTR_READNONE | AC_FUNC_ATTR_CONVERGENT);
+       }
+
        LLVMValueRef pred = LLVMBuildICmp(ctx->builder, LLVMIntEQ, lane,
                                          ac_get_thread_id(ctx), "");
        return LLVMBuildSelect(ctx->builder, pred, value, src, "");