skc7 created this revision.
skc7 added reviewers: sameerds, yaxunl.
Herald added subscribers: t-tye, tpr, dstuttard, jvesely, kzhuravl.
skc7 requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

__builtin_nontemporal_store() fails on AMDGPU. This is due to mismatch in 
address space while creating bitcast. This change matches addrspace of poiter 
type to src addrSpace in EmitNontemporalStore() in clang codegen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114849

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/amdgcn-non-temporal-store.cl


Index: clang/test/CodeGenOpenCL/amdgcn-non-temporal-store.cl
===================================================================
--- /dev/null
+++ clang/test/CodeGenOpenCL/amdgcn-non-temporal-store.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+// CHECK-LABEL: @test_non_temporal_store_kernel
+// CHECK: store i32 0, i32 addrspace(1)* %{{.*}}, align 4, !tbaa !{{.*}}, 
!nontemporal {{.*}}
+
+kernel void test_non_temporal_store_kernel(global unsigned int* io) {
+  __builtin_nontemporal_store(0, io);
+}
\ No newline at end of file
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -170,8 +170,9 @@
 
   // Convert the type of the pointer to a pointer to the stored type.
   Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
+  unsigned SrcAddrSpace = Address->getType()->getPointerAddressSpace();
   Value *BC = CGF.Builder.CreateBitCast(
-      Address, llvm::PointerType::getUnqual(Val->getType()), "cast");
+      Address, llvm::PointerType::get(Val->getType(), SrcAddrSpace), "cast");
   LValue LV = CGF.MakeNaturalAlignAddrLValue(BC, E->getArg(0)->getType());
   LV.setNontemporal(true);
   CGF.EmitStoreOfScalar(Val, LV, false);


Index: clang/test/CodeGenOpenCL/amdgcn-non-temporal-store.cl
===================================================================
--- /dev/null
+++ clang/test/CodeGenOpenCL/amdgcn-non-temporal-store.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+// CHECK-LABEL: @test_non_temporal_store_kernel
+// CHECK: store i32 0, i32 addrspace(1)* %{{.*}}, align 4, !tbaa !{{.*}}, !nontemporal {{.*}}
+
+kernel void test_non_temporal_store_kernel(global unsigned int* io) {
+  __builtin_nontemporal_store(0, io);
+}
\ No newline at end of file
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -170,8 +170,9 @@
 
   // Convert the type of the pointer to a pointer to the stored type.
   Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
+  unsigned SrcAddrSpace = Address->getType()->getPointerAddressSpace();
   Value *BC = CGF.Builder.CreateBitCast(
-      Address, llvm::PointerType::getUnqual(Val->getType()), "cast");
+      Address, llvm::PointerType::get(Val->getType(), SrcAddrSpace), "cast");
   LValue LV = CGF.MakeNaturalAlignAddrLValue(BC, E->getArg(0)->getType());
   LV.setNontemporal(true);
   CGF.EmitStoreOfScalar(Val, LV, false);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D114849:... krishna chaitanya sankisa via Phabricator via cfe-commits

Reply via email to