llvm.org GIT mirror llvm / 2d7d477
Fix CodeGen for vectors of pointers with address spaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193112 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 6 years ago
2 changed file(s) with 37 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
569569 /// otherwise it will assert.
570570 EVT getValueType(Type *Ty, bool AllowUnknown = false) const {
571571 // Lower scalar pointers to native pointer types.
572 if (Ty->isPointerTy()) return getPointerTy(Ty->getPointerAddressSpace());
572 if (PointerType *PTy = dyn_cast(Ty))
573 return getPointerTy(PTy->getAddressSpace());
573574
574575 if (Ty->isVectorTy()) {
575576 VectorType *VTy = cast(Ty);
576577 Type *Elm = VTy->getElementType();
577578 // Lower vectors of pointers to native pointer types.
578 if (Elm->isPointerTy())
579 Elm = EVT(PointerTy).getTypeForEVT(Ty->getContext());
579 if (PointerType *PT = dyn_cast(Elm)) {
580 EVT PointerTy(getPointerTy(PT->getAddressSpace()));
581 Elm = PointerTy.getTypeForEVT(Ty->getContext());
582 }
583
580584 return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false),
581585 VTy->getNumElements());
582586 }
77 ret void
88 }
99
10 define void @gep_as_vector_v4(<4 x [1024 x i32] addrspace(3)*> %array) nounwind {
11 ; CHECK-LABEL: @gep_as_vector_v4:
12 ; CHECK: V_ADD_I32
13 ; CHECK: V_ADD_I32
14 ; CHECK: V_ADD_I32
15 ; CHECK: V_ADD_I32
16 %p = getelementptr <4 x [1024 x i32] addrspace(3)*> %array, <4 x i16> zeroinitializer, <4 x i16>
17 %p0 = extractelement <4 x i32 addrspace(3)*> %p, i32 0
18 %p1 = extractelement <4 x i32 addrspace(3)*> %p, i32 1
19 %p2 = extractelement <4 x i32 addrspace(3)*> %p, i32 2
20 %p3 = extractelement <4 x i32 addrspace(3)*> %p, i32 3
21 store i32 99, i32 addrspace(3)* %p0
22 store i32 99, i32 addrspace(3)* %p1
23 store i32 99, i32 addrspace(3)* %p2
24 store i32 99, i32 addrspace(3)* %p3
25 ret void
26 }
27
28 define void @gep_as_vector_v2(<2 x [1024 x i32] addrspace(3)*> %array) nounwind {
29 ; CHECK-LABEL: @gep_as_vector_v2:
30 ; CHECK: V_ADD_I32
31 ; CHECK: V_ADD_I32
32 %p = getelementptr <2 x [1024 x i32] addrspace(3)*> %array, <2 x i16> zeroinitializer, <2 x i16>
33 %p0 = extractelement <2 x i32 addrspace(3)*> %p, i32 0
34 %p1 = extractelement <2 x i32 addrspace(3)*> %p, i32 1
35 store i32 99, i32 addrspace(3)* %p0
36 store i32 99, i32 addrspace(3)* %p1
37 ret void
38 }
39