1; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
2
3@bufi8 = global [3 x i8] zeroinitializer, align 1
4@bufi16 = global [3 x i16] zeroinitializer, align 2
5@bufi32 = global [3 x i32] zeroinitializer, align 4
6@bufi64 = global [3 x i64] zeroinitializer, align 8
7@bufi128 = global [3 x i128] zeroinitializer, align 16
8@buff32 = global [3 x float] zeroinitializer, align 4
9@buff64 = global [3 x double] zeroinitializer, align 8
10@buff128 = global [3 x fp128] zeroinitializer, align 16
11
12; Function Attrs: noinline nounwind optnone
13define signext i8 @loadi8s() {
14; CHECK-LABEL: loadi8s:
15; CHECK:       # %bb.0: # %entry
16; CHECK-NEXT:    lea %s0, bufi8@lo
17; CHECK-NEXT:    and %s0, %s0, (32)0
18; CHECK-NEXT:    lea.sl %s0, bufi8@hi(, %s0)
19; CHECK-NEXT:    ld1b.sx %s0, 2(, %s0)
20; CHECK-NEXT:    b.l.t (, %s10)
21entry:
22  %0 = load i8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @bufi8, i64 0, i64 2), align 1
23  ret i8 %0
24}
25
26; Function Attrs: noinline nounwind optnone
27define signext i16 @loadi16s() {
28; CHECK-LABEL: loadi16s:
29; CHECK:       # %bb.0: # %entry
30; CHECK-NEXT:    lea %s0, bufi16@lo
31; CHECK-NEXT:    and %s0, %s0, (32)0
32; CHECK-NEXT:    lea.sl %s0, bufi16@hi(, %s0)
33; CHECK-NEXT:    ld2b.sx %s0, 4(, %s0)
34; CHECK-NEXT:    b.l.t (, %s10)
35entry:
36  %0 = load i16, i16* getelementptr inbounds ([3 x i16], [3 x i16]* @bufi16, i64 0, i64 2), align 2
37  ret i16 %0
38}
39
40; Function Attrs: noinline nounwind optnone
41define signext i32 @loadi32s() {
42; CHECK-LABEL: loadi32s:
43; CHECK:       # %bb.0: # %entry
44; CHECK-NEXT:    lea %s0, bufi32@lo
45; CHECK-NEXT:    and %s0, %s0, (32)0
46; CHECK-NEXT:    lea.sl %s0, bufi32@hi(, %s0)
47; CHECK-NEXT:    ldl.sx %s0, 8(, %s0)
48; CHECK-NEXT:    b.l.t (, %s10)
49entry:
50  %0 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @bufi32, i64 0, i64 2), align 4
51  ret i32 %0
52}
53
54; Function Attrs: noinline nounwind optnone
55define i64 @loadi64s() {
56; CHECK-LABEL: loadi64s:
57; CHECK:       # %bb.0: # %entry
58; CHECK-NEXT:    lea %s0, bufi64@lo
59; CHECK-NEXT:    and %s0, %s0, (32)0
60; CHECK-NEXT:    lea.sl %s0, bufi64@hi(, %s0)
61; CHECK-NEXT:    ld %s0, 16(, %s0)
62; CHECK-NEXT:    b.l.t (, %s10)
63entry:
64  %0 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @bufi64, i64 0, i64 2), align 8
65  ret i64 %0
66}
67
68; Function Attrs: noinline nounwind optnone
69define i128 @loadi128s() {
70; CHECK-LABEL: loadi128s:
71; CHECK:       # %bb.0: # %entry
72; CHECK-NEXT:    lea %s0, bufi128@lo
73; CHECK-NEXT:    and %s0, %s0, (32)0
74; CHECK-NEXT:    lea.sl %s1, bufi128@hi(, %s0)
75; CHECK-NEXT:    ld %s0, 32(, %s1)
76; CHECK-NEXT:    ld %s1, 40(, %s1)
77; CHECK-NEXT:    b.l.t (, %s10)
78entry:
79  %0 = load i128, i128* getelementptr inbounds ([3 x i128], [3 x i128]* @bufi128, i64 0, i64 2), align 16
80  ret i128 %0
81}
82
83; Function Attrs: noinline nounwind optnone
84define zeroext i8 @loadi8z() {
85; CHECK-LABEL: loadi8z:
86; CHECK:       # %bb.0: # %entry
87; CHECK-NEXT:    lea %s0, bufi8@lo
88; CHECK-NEXT:    and %s0, %s0, (32)0
89; CHECK-NEXT:    lea.sl %s0, bufi8@hi(, %s0)
90; CHECK-NEXT:    ld1b.zx %s0, 2(, %s0)
91; CHECK-NEXT:    b.l.t (, %s10)
92entry:
93  %0 = load i8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @bufi8, i64 0, i64 2), align 1
94  ret i8 %0
95}
96
97; Function Attrs: noinline nounwind optnone
98define zeroext i16 @loadi16z() {
99; CHECK-LABEL: loadi16z:
100; CHECK:       # %bb.0: # %entry
101; CHECK-NEXT:    lea %s0, bufi16@lo
102; CHECK-NEXT:    and %s0, %s0, (32)0
103; CHECK-NEXT:    lea.sl %s0, bufi16@hi(, %s0)
104; CHECK-NEXT:    ld2b.zx %s0, 4(, %s0)
105; CHECK-NEXT:    b.l.t (, %s10)
106entry:
107  %0 = load i16, i16* getelementptr inbounds ([3 x i16], [3 x i16]* @bufi16, i64 0, i64 2), align 2
108  ret i16 %0
109}
110
111; Function Attrs: noinline nounwind optnone
112define zeroext i32 @loadi32z() {
113; CHECK-LABEL: loadi32z:
114; CHECK:       # %bb.0: # %entry
115; CHECK-NEXT:    lea %s0, bufi32@lo
116; CHECK-NEXT:    and %s0, %s0, (32)0
117; CHECK-NEXT:    lea.sl %s0, bufi32@hi(, %s0)
118; CHECK-NEXT:    ldl.zx %s0, 8(, %s0)
119; CHECK-NEXT:    b.l.t (, %s10)
120entry:
121  %0 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @bufi32, i64 0, i64 2), align 4
122  ret i32 %0
123}
124
125; Function Attrs: noinline nounwind optnone
126define i64 @loadi64z() {
127; CHECK-LABEL: loadi64z:
128; CHECK:       # %bb.0: # %entry
129; CHECK-NEXT:    lea %s0, bufi64@lo
130; CHECK-NEXT:    and %s0, %s0, (32)0
131; CHECK-NEXT:    lea.sl %s0, bufi64@hi(, %s0)
132; CHECK-NEXT:    ld %s0, 16(, %s0)
133; CHECK-NEXT:    b.l.t (, %s10)
134entry:
135  %0 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @bufi64, i64 0, i64 2), align 8
136  ret i64 %0
137}
138
139; Function Attrs: noinline nounwind optnone
140define i128 @loadi128z() {
141; CHECK-LABEL: loadi128z:
142; CHECK:       # %bb.0: # %entry
143; CHECK-NEXT:    lea %s0, bufi128@lo
144; CHECK-NEXT:    and %s0, %s0, (32)0
145; CHECK-NEXT:    lea.sl %s1, bufi128@hi(, %s0)
146; CHECK-NEXT:    ld %s0, 32(, %s1)
147; CHECK-NEXT:    ld %s1, 40(, %s1)
148; CHECK-NEXT:    b.l.t (, %s10)
149entry:
150  %0 = load i128, i128* getelementptr inbounds ([3 x i128], [3 x i128]* @bufi128, i64 0, i64 2), align 16
151  ret i128 %0
152}
153
154; Function Attrs: noinline nounwind optnone
155define float @loadf32() {
156; CHECK-LABEL: loadf32:
157; CHECK:       # %bb.0: # %entry
158; CHECK-NEXT:    lea %s0, buff32@lo
159; CHECK-NEXT:    and %s0, %s0, (32)0
160; CHECK-NEXT:    lea.sl %s0, buff32@hi(, %s0)
161; CHECK-NEXT:    ldu %s0, 8(, %s0)
162; CHECK-NEXT:    b.l.t (, %s10)
163entry:
164  %0 = load float, float* getelementptr inbounds ([3 x float], [3 x float]* @buff32, i64 0, i64 2), align 4
165  ret float %0
166}
167
168; Function Attrs: noinline nounwind optnone
169define double @loadf64() {
170; CHECK-LABEL: loadf64:
171; CHECK:       # %bb.0: # %entry
172; CHECK-NEXT:    lea %s0, buff64@lo
173; CHECK-NEXT:    and %s0, %s0, (32)0
174; CHECK-NEXT:    lea.sl %s0, buff64@hi(, %s0)
175; CHECK-NEXT:    ld %s0, 16(, %s0)
176; CHECK-NEXT:    b.l.t (, %s10)
177entry:
178  %0 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @buff64, i64 0, i64 2), align 8
179  ret double %0
180}
181
182; Function Attrs: noinline nounwind optnone
183define fp128 @loadf128() {
184; CHECK-LABEL: loadf128:
185; CHECK:       # %bb.0: # %entry
186; CHECK-NEXT:    lea %s0, buff128@lo
187; CHECK-NEXT:    and %s0, %s0, (32)0
188; CHECK-NEXT:    lea.sl %s2, buff128@hi(, %s0)
189; CHECK-NEXT:    ld %s0, 40(, %s2)
190; CHECK-NEXT:    ld %s1, 32(, %s2)
191; CHECK-NEXT:    b.l.t (, %s10)
192entry:
193  %0 = load fp128, fp128* getelementptr inbounds ([3 x fp128], [3 x fp128]* @buff128, i64 0, i64 2), align 16
194  ret fp128 %0
195}
196