1 ; RUN: opt -load-store-vectorizer -S < %s | FileCheck %s
3 target datalayout = "e-p:64:64-p1:64:64-p5:32:32"
5 ; Size mismatch between the 32 bit pointer in address space 5 and 64 bit
6 ; pointer in address space 0 it was cast to caused below test to crash.
7 ; The p5:32:32 portion of the data layout is critical for the test.
9 ; CHECK-LABEL: @cast_to_ptr
10 ; CHECK: store i32* undef, i32** %tmp9, align 8
11 ; CHECK: store i32* undef, i32** %tmp7, align 8
12 define void @cast_to_ptr() {
14 %ascast = addrspacecast i32* addrspace(5)* null to i32**
15 %tmp4 = icmp eq i32 undef, 0
16 %tmp6 = select i1 false, i32** undef, i32** undef
17 %tmp7 = select i1 %tmp4, i32** null, i32** %tmp6
18 %tmp9 = select i1 %tmp4, i32** %ascast, i32** null
19 store i32* undef, i32** %tmp9, align 8
20 store i32* undef, i32** %tmp7, align 8
24 ; CHECK-LABEL: @cast_to_cast
25 ; CHECK: %tmp4 = load i32*, i32** %tmp1, align 8
26 ; CHECK: %tmp5 = load i32*, i32** %tmp3, align 8
27 define void @cast_to_cast() {
29 %a.ascast = addrspacecast i32* addrspace(5)* undef to i32**
30 %b.ascast = addrspacecast i32* addrspace(5)* null to i32**
31 %tmp1 = select i1 false, i32** %a.ascast, i32** undef
32 %tmp3 = select i1 false, i32** %b.ascast, i32** undef
33 %tmp4 = load i32*, i32** %tmp1, align 8
34 %tmp5 = load i32*, i32** %tmp3, align 8
38 ; CHECK-LABEL: @all_to_cast
39 ; CHECK: load <4 x float>
40 define void @all_to_cast(i8* nocapture readonly align 16 dereferenceable(16) %alloc1) {
42 %alloc16 = addrspacecast i8* %alloc1 to i8 addrspace(1)*
43 %tmp = bitcast i8 addrspace(1)* %alloc16 to float addrspace(1)*
44 %tmp1 = load float, float addrspace(1)* %tmp, align 16, !invariant.load !0
45 %tmp6 = getelementptr inbounds i8, i8 addrspace(1)* %alloc16, i64 4
46 %tmp7 = bitcast i8 addrspace(1)* %tmp6 to float addrspace(1)*
47 %tmp8 = load float, float addrspace(1)* %tmp7, align 4, !invariant.load !0
48 %tmp15 = getelementptr inbounds i8, i8 addrspace(1)* %alloc16, i64 8
49 %tmp16 = bitcast i8 addrspace(1)* %tmp15 to float addrspace(1)*
50 %tmp17 = load float, float addrspace(1)* %tmp16, align 8, !invariant.load !0
51 %tmp24 = getelementptr inbounds i8, i8 addrspace(1)* %alloc16, i64 12
52 %tmp25 = bitcast i8 addrspace(1)* %tmp24 to float addrspace(1)*
53 %tmp26 = load float, float addrspace(1)* %tmp25, align 4, !invariant.load !0
57 ; CHECK-LABEL: @ext_ptr
58 ; CHECK load <2 x i32>
59 define void @ext_ptr(i32 addrspace(5)* %p) {
61 %gep1 = getelementptr inbounds i32, i32 addrspace(5)* %p, i64 0
62 %gep2 = getelementptr inbounds i32, i32 addrspace(5)* %p, i64 1
63 %a.ascast = addrspacecast i32 addrspace(5)* %gep1 to i32*
64 %b.ascast = addrspacecast i32 addrspace(5)* %gep2 to i32*
65 %tmp1 = load i32, i32* %a.ascast, align 8
66 %tmp2 = load i32, i32* %b.ascast, align 8
70 ; CHECK-LABEL: @shrink_ptr
71 ; CHECK load <2 x i32>
72 define void @shrink_ptr(i32* %p) {
74 %gep1 = getelementptr inbounds i32, i32* %p, i64 0
75 %gep2 = getelementptr inbounds i32, i32* %p, i64 1
76 %a.ascast = addrspacecast i32* %gep1 to i32 addrspace(5)*
77 %b.ascast = addrspacecast i32* %gep2 to i32 addrspace(5)*
78 %tmp1 = load i32, i32 addrspace(5)* %a.ascast, align 8
79 %tmp2 = load i32, i32 addrspace(5)* %b.ascast, align 8
83 ; CHECK-LABEL: @ext_ptr_wrap
84 ; CHECK: load <2 x i8>
85 define void @ext_ptr_wrap(i8 addrspace(5)* %p) {
87 %gep1 = getelementptr inbounds i8, i8 addrspace(5)* %p, i64 0
88 %gep2 = getelementptr inbounds i8, i8 addrspace(5)* %p, i64 4294967295
89 %a.ascast = addrspacecast i8 addrspace(5)* %gep1 to i8*
90 %b.ascast = addrspacecast i8 addrspace(5)* %gep2 to i8*
91 %tmp1 = load i8, i8* %a.ascast, align 1
92 %tmp2 = load i8, i8* %b.ascast, align 1