summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-10-21 20:03:58 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-10-21 20:03:58 +0000
commit51f9f774948216b56a5a0a763f52c1cbdd260a32 (patch)
tree3b5485d16974340b82edb1b50b888388851f24f2 /llvm
parentb768912db853b13b148a388f0dd03ecaa80ae785 (diff)
downloadbcm5719-llvm-51f9f774948216b56a5a0a763f52c1cbdd260a32.tar.gz
bcm5719-llvm-51f9f774948216b56a5a0a763f52c1cbdd260a32.zip
Fix CodeGen for vectors of pointers with address spaces.
llvm-svn: 193112
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Target/TargetLowering.h10
-rw-r--r--llvm/test/CodeGen/R600/gep-address-space.ll30
2 files changed, 37 insertions, 3 deletions
diff --git a/llvm/include/llvm/Target/TargetLowering.h b/llvm/include/llvm/Target/TargetLowering.h
index 8aa0abdb5e1..51d9e009968 100644
--- a/llvm/include/llvm/Target/TargetLowering.h
+++ b/llvm/include/llvm/Target/TargetLowering.h
@@ -570,14 +570,18 @@ public:
/// otherwise it will assert.
EVT getValueType(Type *Ty, bool AllowUnknown = false) const {
// Lower scalar pointers to native pointer types.
- if (Ty->isPointerTy()) return getPointerTy(Ty->getPointerAddressSpace());
+ if (PointerType *PTy = dyn_cast<PointerType>(Ty))
+ return getPointerTy(PTy->getAddressSpace());
if (Ty->isVectorTy()) {
VectorType *VTy = cast<VectorType>(Ty);
Type *Elm = VTy->getElementType();
// Lower vectors of pointers to native pointer types.
- if (Elm->isPointerTy())
- Elm = EVT(PointerTy).getTypeForEVT(Ty->getContext());
+ if (PointerType *PT = dyn_cast<PointerType>(Elm)) {
+ EVT PointerTy(getPointerTy(PT->getAddressSpace()));
+ Elm = PointerTy.getTypeForEVT(Ty->getContext());
+ }
+
return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false),
VTy->getNumElements());
}
diff --git a/llvm/test/CodeGen/R600/gep-address-space.ll b/llvm/test/CodeGen/R600/gep-address-space.ll
index 6c67ed43619..934b5a5956e 100644
--- a/llvm/test/CodeGen/R600/gep-address-space.ll
+++ b/llvm/test/CodeGen/R600/gep-address-space.ll
@@ -8,3 +8,33 @@ define void @use_gep_address_space([1024 x i32] addrspace(3)* %array) nounwind {
ret void
}
+define void @gep_as_vector_v4(<4 x [1024 x i32] addrspace(3)*> %array) nounwind {
+; CHECK-LABEL: @gep_as_vector_v4:
+; CHECK: V_ADD_I32
+; CHECK: V_ADD_I32
+; CHECK: V_ADD_I32
+; CHECK: V_ADD_I32
+ %p = getelementptr <4 x [1024 x i32] addrspace(3)*> %array, <4 x i16> zeroinitializer, <4 x i16> <i16 16, i16 16, i16 16, i16 16>
+ %p0 = extractelement <4 x i32 addrspace(3)*> %p, i32 0
+ %p1 = extractelement <4 x i32 addrspace(3)*> %p, i32 1
+ %p2 = extractelement <4 x i32 addrspace(3)*> %p, i32 2
+ %p3 = extractelement <4 x i32 addrspace(3)*> %p, i32 3
+ store i32 99, i32 addrspace(3)* %p0
+ store i32 99, i32 addrspace(3)* %p1
+ store i32 99, i32 addrspace(3)* %p2
+ store i32 99, i32 addrspace(3)* %p3
+ ret void
+}
+
+define void @gep_as_vector_v2(<2 x [1024 x i32] addrspace(3)*> %array) nounwind {
+; CHECK-LABEL: @gep_as_vector_v2:
+; CHECK: V_ADD_I32
+; CHECK: V_ADD_I32
+ %p = getelementptr <2 x [1024 x i32] addrspace(3)*> %array, <2 x i16> zeroinitializer, <2 x i16> <i16 16, i16 16>
+ %p0 = extractelement <2 x i32 addrspace(3)*> %p, i32 0
+ %p1 = extractelement <2 x i32 addrspace(3)*> %p, i32 1
+ store i32 99, i32 addrspace(3)* %p0
+ store i32 99, i32 addrspace(3)* %p1
+ ret void
+}
+
OpenPOWER on IntegriCloud