[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment
Anastasia Stulova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 13 06:27:00 PDT 2017
Anastasia created this revision.
Added missing `addrspacecast` case in alignment computation logic of pointer type emission in IR generation.
https://reviews.llvm.org/D37804
Files:
lib/CodeGen/CGExpr.cpp
test/CodeGenOpenCL/vectorLoadStore.cl
Index: test/CodeGenOpenCL/vectorLoadStore.cl
===================================================================
--- test/CodeGenOpenCL/vectorLoadStore.cl
+++ test/CodeGenOpenCL/vectorLoadStore.cl
@@ -1,9 +1,23 @@
// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
-typedef char char3 __attribute((ext_vector_type(3)));;
+typedef char char2 __attribute((ext_vector_type(2)));
+typedef char char3 __attribute((ext_vector_type(3)));
+typedef char char8 __attribute((ext_vector_type(8)));
+typedef float float4 __attribute((ext_vector_type(4)));
+;
// Check for optimized vec3 load/store which treats vec3 as vec4.
void foo(char3 *P, char3 *Q) {
*P = *Q;
// CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x i32> <i32 0, i32 1, i32 2>
}
+
+// CHECK: define spir_func void @alignment()
+void alignment() {
+ __private char2 data_generic[100];
+ __private char8 data_private[100];
+
+ // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, align 2
+ // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8
+ ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2];
+}
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -924,6 +924,7 @@
// Non-converting casts (but not C's implicit conversion from void*).
case CK_BitCast:
case CK_NoOp:
+ case CK_AddressSpaceConversion:
if (auto PtrTy = CE->getSubExpr()->getType()->getAs<PointerType>()) {
if (PtrTy->getPointeeType()->isVoidType())
break;
@@ -953,7 +954,8 @@
CE->getLocStart());
}
- return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+ return Builder.CreatePointerBitCastOrAddrSpaceCast(
+ Addr, ConvertType(E->getType()));
}
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37804.115025.patch
Type: text/x-patch
Size: 1916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170913/79e94206/attachment.bin>
More information about the cfe-commits
mailing list