store-constant.ll
8.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 -verify-machineinstrs | FileCheck %s
@CVal = external local_unnamed_addr global i8, align 1
@SVal = external local_unnamed_addr global i16, align 2
@IVal = external local_unnamed_addr global i32, align 4
@LVal = external local_unnamed_addr global i64, align 8
@USVal = external local_unnamed_addr global i16, align 2
@arr = external local_unnamed_addr global i64*, align 8
@arri = external local_unnamed_addr global i32*, align 8
; Test the same constant can be used by different stores.
%struct.S = type { i64, i8, i16, i32 }
define void @foo(%struct.S* %p) {
; CHECK-LABEL: foo:
; CHECK: # %bb.0:
; CHECK-NEXT: li 4, 0
; CHECK-NEXT: stb 4, 8(3)
; CHECK-NEXT: std 4, 0(3)
; CHECK-NEXT: sth 4, 10(3)
; CHECK-NEXT: stw 4, 12(3)
; CHECK-NEXT: blr
%l4 = bitcast %struct.S* %p to i64*
store i64 0, i64* %l4, align 8
%c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1
store i8 0, i8* %c, align 8
%s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2
store i16 0, i16* %s, align 2
%i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3
store i32 0, i32* %i, align 4
ret void
}
define void @bar(%struct.S* %p) {
; CHECK-LABEL: bar:
; CHECK: # %bb.0:
; CHECK-NEXT: li 4, 2
; CHECK-NEXT: stw 4, 12(3)
; CHECK-NEXT: sth 4, 10(3)
; CHECK-NEXT: std 4, 0(3)
; CHECK-NEXT: stb 4, 8(3)
; CHECK-NEXT: blr
%i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3
store i32 2, i32* %i, align 4
%s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2
store i16 2, i16* %s, align 2
%c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1
store i8 2, i8* %c, align 8
%l4 = bitcast %struct.S* %p to i64*
store i64 2, i64* %l4, align 8
ret void
}
; Function Attrs: norecurse nounwind
define void @setSmallNeg() {
; CHECK-LABEL: setSmallNeg:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC0@toc@ha
; CHECK-NEXT: addis 4, 2, .LC1@toc@ha
; CHECK-NEXT: addis 5, 2, .LC2@toc@ha
; CHECK-NEXT: addis 6, 2, .LC3@toc@ha
; CHECK-NEXT: li 7, -7
; CHECK-NEXT: ld 3, .LC0@toc@l(3)
; CHECK-NEXT: ld 4, .LC1@toc@l(4)
; CHECK-NEXT: ld 5, .LC2@toc@l(5)
; CHECK-NEXT: ld 6, .LC3@toc@l(6)
; CHECK-NEXT: stb 7, 0(3)
; CHECK-NEXT: sth 7, 0(4)
; CHECK-NEXT: std 7, 0(6)
; CHECK-NEXT: stw 7, 0(5)
; CHECK-NEXT: blr
entry:
store i8 -7, i8* @CVal, align 1
store i16 -7, i16* @SVal, align 2
store i32 -7, i32* @IVal, align 4
store i64 -7, i64* @LVal, align 8
ret void
}
; Function Attrs: norecurse nounwind
define void @setSmallPos() {
; CHECK-LABEL: setSmallPos:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC0@toc@ha
; CHECK-NEXT: addis 4, 2, .LC1@toc@ha
; CHECK-NEXT: addis 5, 2, .LC2@toc@ha
; CHECK-NEXT: addis 6, 2, .LC3@toc@ha
; CHECK-NEXT: li 7, 8
; CHECK-NEXT: ld 3, .LC0@toc@l(3)
; CHECK-NEXT: ld 4, .LC1@toc@l(4)
; CHECK-NEXT: ld 5, .LC2@toc@l(5)
; CHECK-NEXT: ld 6, .LC3@toc@l(6)
; CHECK-NEXT: stb 7, 0(3)
; CHECK-NEXT: sth 7, 0(4)
; CHECK-NEXT: std 7, 0(6)
; CHECK-NEXT: stw 7, 0(5)
; CHECK-NEXT: blr
entry:
store i8 8, i8* @CVal, align 1
store i16 8, i16* @SVal, align 2
store i32 8, i32* @IVal, align 4
store i64 8, i64* @LVal, align 8
ret void
}
; Function Attrs: norecurse nounwind
define void @setMaxNeg() {
; CHECK-LABEL: setMaxNeg:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC1@toc@ha
; CHECK-NEXT: addis 4, 2, .LC2@toc@ha
; CHECK-NEXT: addis 5, 2, .LC3@toc@ha
; CHECK-NEXT: li 6, -32768
; CHECK-NEXT: ld 3, .LC1@toc@l(3)
; CHECK-NEXT: ld 4, .LC2@toc@l(4)
; CHECK-NEXT: ld 5, .LC3@toc@l(5)
; CHECK-NEXT: sth 6, 0(3)
; CHECK-NEXT: stw 6, 0(4)
; CHECK-NEXT: std 6, 0(5)
; CHECK-NEXT: blr
entry:
store i16 -32768, i16* @SVal, align 2
store i32 -32768, i32* @IVal, align 4
store i64 -32768, i64* @LVal, align 8
ret void
}
; Function Attrs: norecurse nounwind
define void @setMaxPos() {
; CHECK-LABEL: setMaxPos:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC1@toc@ha
; CHECK-NEXT: addis 4, 2, .LC2@toc@ha
; CHECK-NEXT: addis 5, 2, .LC3@toc@ha
; CHECK-NEXT: li 6, 32767
; CHECK-NEXT: ld 3, .LC1@toc@l(3)
; CHECK-NEXT: ld 4, .LC2@toc@l(4)
; CHECK-NEXT: ld 5, .LC3@toc@l(5)
; CHECK-NEXT: sth 6, 0(3)
; CHECK-NEXT: stw 6, 0(4)
; CHECK-NEXT: std 6, 0(5)
; CHECK-NEXT: blr
entry:
store i16 32767, i16* @SVal, align 2
store i32 32767, i32* @IVal, align 4
store i64 32767, i64* @LVal, align 8
ret void
}
; Function Attrs: norecurse nounwind
define void @setExcessiveNeg() {
; CHECK-LABEL: setExcessiveNeg:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC2@toc@ha
; CHECK-NEXT: addis 4, 2, .LC3@toc@ha
; CHECK-NEXT: lis 5, -1
; CHECK-NEXT: ld 3, .LC2@toc@l(3)
; CHECK-NEXT: ld 4, .LC3@toc@l(4)
; CHECK-NEXT: ori 5, 5, 32767
; CHECK-NEXT: stw 5, 0(3)
; CHECK-NEXT: std 5, 0(4)
; CHECK-NEXT: blr
entry:
store i32 -32769, i32* @IVal, align 4
store i64 -32769, i64* @LVal, align 8
ret void
}
; Function Attrs: norecurse nounwind
define void @setExcessivePos() {
; CHECK-LABEL: setExcessivePos:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC4@toc@ha
; CHECK-NEXT: addis 4, 2, .LC2@toc@ha
; CHECK-NEXT: addis 5, 2, .LC3@toc@ha
; CHECK-NEXT: li 6, 0
; CHECK-NEXT: ld 3, .LC4@toc@l(3)
; CHECK-NEXT: ld 4, .LC2@toc@l(4)
; CHECK-NEXT: ld 5, .LC3@toc@l(5)
; CHECK-NEXT: ori 6, 6, 32768
; CHECK-NEXT: sth 6, 0(3)
; CHECK-NEXT: stw 6, 0(4)
; CHECK-NEXT: std 6, 0(5)
; CHECK-NEXT: blr
entry:
store i16 -32768, i16* @USVal, align 2
store i32 32768, i32* @IVal, align 4
store i64 32768, i64* @LVal, align 8
ret void
}
define void @SetArr(i32 signext %Len) {
; CHECK-LABEL: SetArr:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: cmpwi 3, 1
; CHECK-NEXT: bltlr 0
; CHECK-NEXT: # %bb.1: # %for.body.lr.ph
; CHECK-NEXT: addis 4, 2, .LC5@toc@ha
; CHECK-NEXT: addis 5, 2, .LC6@toc@ha
; CHECK-NEXT: clrldi 6, 3, 32
; CHECK-NEXT: ld 4, .LC5@toc@l(4)
; CHECK-NEXT: ld 5, .LC6@toc@l(5)
; CHECK-NEXT: ld 4, 0(4)
; CHECK-NEXT: ld 5, 0(5)
; CHECK-NEXT: mtctr 6
; CHECK-NEXT: addi 3, 4, -8
; CHECK-NEXT: addi 4, 5, -4
; CHECK-NEXT: li 5, -7
; CHECK-NEXT: .p2align 4
; CHECK-NEXT: .LBB8_2: # %for.body
; CHECK-NEXT: #
; CHECK-NEXT: stdu 5, 8(3)
; CHECK-NEXT: stwu 5, 4(4)
; CHECK-NEXT: bdnz .LBB8_2
; CHECK-NEXT: # %bb.3: # %for.cond.cleanup
; CHECK-NEXT: blr
entry:
%cmp7 = icmp sgt i32 %Len, 0
br i1 %cmp7, label %for.body.lr.ph, label %for.cond.cleanup
for.body.lr.ph: ; preds = %entry
%0 = load i64*, i64** @arr, align 8
%1 = load i32*, i32** @arri, align 8
%wide.trip.count = zext i32 %Len to i64
br label %for.body
for.cond.cleanup: ; preds = %for.body, %entry
ret void
for.body: ; preds = %for.body, %for.body.lr.ph
%indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
%arrayidx = getelementptr inbounds i64, i64* %0, i64 %indvars.iv
store i64 -7, i64* %arrayidx, align 8
%arrayidx2 = getelementptr inbounds i32, i32* %1, i64 %indvars.iv
store i32 -7, i32* %arrayidx2, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond, label %for.cond.cleanup, label %for.body
}
define void @setSameValDiffSizeCI() {
; CHECK-LABEL: setSameValDiffSizeCI:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC2@toc@ha
; CHECK-NEXT: addis 4, 2, .LC0@toc@ha
; CHECK-NEXT: li 5, 255
; CHECK-NEXT: ld 3, .LC2@toc@l(3)
; CHECK-NEXT: ld 4, .LC0@toc@l(4)
; CHECK-NEXT: stw 5, 0(3)
; CHECK-NEXT: stb 5, 0(4)
; CHECK-NEXT: blr
entry:
store i32 255, i32* @IVal, align 4
store i8 -1, i8* @CVal, align 1
ret void
}
define void @setSameValDiffSizeSI() {
; CHECK-LABEL: setSameValDiffSizeSI:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LC2@toc@ha
; CHECK-NEXT: addis 4, 2, .LC1@toc@ha
; CHECK-NEXT: li 5, 0
; CHECK-NEXT: ld 3, .LC2@toc@l(3)
; CHECK-NEXT: ld 4, .LC1@toc@l(4)
; CHECK-NEXT: ori 5, 5, 65535
; CHECK-NEXT: stw 5, 0(3)
; CHECK-NEXT: sth 5, 0(4)
; CHECK-NEXT: blr
entry:
store i32 65535, i32* @IVal, align 4
store i16 -1, i16* @SVal, align 2
ret void
}