1 ; RUN: opt -passes=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 ptr undef, ptr %tmp9, align 8
11 ; CHECK: store ptr undef, ptr %tmp7, align 8
12 define void @cast_to_ptr() {
14 %ascast = addrspacecast ptr addrspace(5) null to ptr
15 %tmp4 = icmp eq i32 undef, 0
16 %tmp6 = select i1 false, ptr undef, ptr undef
17 %tmp7 = select i1 %tmp4, ptr null, ptr %tmp6
18 %tmp9 = select i1 %tmp4, ptr %ascast, ptr null
19 store ptr undef, ptr %tmp9, align 8
20 store ptr undef, ptr %tmp7, align 8
24 ; CHECK-LABEL: @cast_to_cast
25 ; CHECK: %tmp4 = load ptr, ptr %tmp1, align 8
26 ; CHECK: %tmp5 = load ptr, ptr %tmp3, align 8
27 define void @cast_to_cast() {
29 %a.ascast = addrspacecast ptr addrspace(5) undef to ptr
30 %b.ascast = addrspacecast ptr addrspace(5) null to ptr
31 %tmp1 = select i1 false, ptr %a.ascast, ptr undef
32 %tmp3 = select i1 false, ptr %b.ascast, ptr undef
33 %tmp4 = load ptr, ptr %tmp1, align 8
34 %tmp5 = load ptr, ptr %tmp3, align 8
38 ; CHECK-LABEL: @all_to_cast
39 ; CHECK: load <4 x float>
40 define void @all_to_cast(ptr nocapture readonly align 16 dereferenceable(16) %alloc1) {
42 %alloc16 = addrspacecast ptr %alloc1 to ptr addrspace(1)
43 %tmp1 = load float, ptr addrspace(1) %alloc16, align 16, !invariant.load !0
44 %tmp6 = getelementptr inbounds i8, ptr addrspace(1) %alloc16, i64 4
45 %tmp8 = load float, ptr addrspace(1) %tmp6, align 4, !invariant.load !0
46 %tmp15 = getelementptr inbounds i8, ptr addrspace(1) %alloc16, i64 8
47 %tmp17 = load float, ptr addrspace(1) %tmp15, align 8, !invariant.load !0
48 %tmp24 = getelementptr inbounds i8, ptr addrspace(1) %alloc16, i64 12
49 %tmp26 = load float, ptr addrspace(1) %tmp24, align 4, !invariant.load !0
53 ; CHECK-LABEL: @ext_ptr
54 ; CHECK: load <2 x i32>
55 define void @ext_ptr(ptr addrspace(5) %p) {
57 %gep2 = getelementptr inbounds i32, ptr addrspace(5) %p, i64 1
58 %a.ascast = addrspacecast ptr addrspace(5) %p to ptr
59 %b.ascast = addrspacecast ptr addrspace(5) %gep2 to ptr
60 %tmp1 = load i32, ptr %a.ascast, align 8
61 %tmp2 = load i32, ptr %b.ascast, align 8
65 ; CHECK-LABEL: @select_different_as
66 ; CHECK: load <2 x i32>
67 define void @select_different_as(ptr addrspace(1) %p0, ptr addrspace(5) %q0, i1 %cond) {
69 %p1 = getelementptr inbounds i32, ptr addrspace(1) %p0, i64 1
70 %q1 = getelementptr inbounds i32, ptr addrspace(5) %q0, i64 1
71 %p0.ascast = addrspacecast ptr addrspace(1) %p0 to ptr
72 %p1.ascast = addrspacecast ptr addrspace(1) %p1 to ptr
73 %q0.ascast = addrspacecast ptr addrspace(5) %q0 to ptr
74 %q1.ascast = addrspacecast ptr addrspace(5) %q1 to ptr
75 %sel0 = select i1 %cond, ptr %p0.ascast, ptr %q0.ascast
76 %sel1 = select i1 %cond, ptr %p1.ascast, ptr %q1.ascast
77 %tmp1 = load i32, ptr %sel0, align 8
78 %tmp2 = load i32, ptr %sel1, align 8
82 ; CHECK-LABEL: @shrink_ptr
83 ; CHECK: load <2 x i32>
84 define void @shrink_ptr(ptr %p) {
86 %gep2 = getelementptr inbounds i32, ptr %p, i64 1
87 %a.ascast = addrspacecast ptr %p to ptr addrspace(5)
88 %b.ascast = addrspacecast ptr %gep2 to ptr addrspace(5)
89 %tmp1 = load i32, ptr addrspace(5) %a.ascast, align 8
90 %tmp2 = load i32, ptr addrspace(5) %b.ascast, align 8
94 ; CHECK-LABEL: @ext_ptr_wrap
95 ; CHECK: load <2 x i8>
96 define void @ext_ptr_wrap(ptr addrspace(5) %p) {
98 %gep2 = getelementptr inbounds i8, ptr addrspace(5) %p, i64 4294967295
99 %a.ascast = addrspacecast ptr addrspace(5) %p to ptr
100 %b.ascast = addrspacecast ptr addrspace(5) %gep2 to ptr
101 %tmp1 = load i8, ptr %a.ascast, align 1
102 %tmp2 = load i8, ptr %b.ascast, align 2