store-narrow.ll
6.69 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
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; rdar://7860110
; RUN: llc -mtriple=x86_64-apple-darwin10.2 < %s | FileCheck %s -check-prefix=X64
; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=1 < %s | FileCheck %s -check-prefix=X32 -check-prefix=X32-BWON
; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=0 < %s | FileCheck %s -check-prefix=X32 -check-prefix=X32-BWOFF
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
define void @test1(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
; X64-LABEL: test1:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movb %sil, (%rdi)
; X64-NEXT: retq
;
; X32-LABEL: test1:
; X32: ## %bb.0: ## %entry
; X32-NEXT: movb {{[0-9]+}}(%esp), %al
; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-NEXT: movb %al, (%ecx)
; X32-NEXT: retl
entry:
%A = load i32, i32* %a0, align 4
%B = and i32 %A, -256 ; 0xFFFFFF00
%C = zext i8 %a1 to i32
%D = or i32 %C, %B
store i32 %D, i32* %a0, align 4
ret void
}
define void @test2(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
; X64-LABEL: test2:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movb %sil, 1(%rdi)
; X64-NEXT: retq
;
; X32-LABEL: test2:
; X32: ## %bb.0: ## %entry
; X32-NEXT: movb {{[0-9]+}}(%esp), %al
; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-NEXT: movb %al, 1(%ecx)
; X32-NEXT: retl
entry:
%A = load i32, i32* %a0, align 4
%B = and i32 %A, -65281 ; 0xFFFF00FF
%C = zext i8 %a1 to i32
%CS = shl i32 %C, 8
%D = or i32 %B, %CS
store i32 %D, i32* %a0, align 4
ret void
}
define void @test3(i32* nocapture %a0, i16 zeroext %a1) nounwind ssp {
; X64-LABEL: test3:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movw %si, (%rdi)
; X64-NEXT: retq
;
; X32-BWON-LABEL: test3:
; X32-BWON: ## %bb.0: ## %entry
; X32-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
; X32-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-BWON-NEXT: movw %ax, (%ecx)
; X32-BWON-NEXT: retl
;
; X32-BWOFF-LABEL: test3:
; X32-BWOFF: ## %bb.0: ## %entry
; X32-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
; X32-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-BWOFF-NEXT: movw %ax, (%ecx)
; X32-BWOFF-NEXT: retl
entry:
%A = load i32, i32* %a0, align 4
%B = and i32 %A, -65536 ; 0xFFFF0000
%C = zext i16 %a1 to i32
%D = or i32 %B, %C
store i32 %D, i32* %a0, align 4
ret void
}
define void @test4(i32* nocapture %a0, i16 zeroext %a1) nounwind ssp {
; X64-LABEL: test4:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movw %si, 2(%rdi)
; X64-NEXT: retq
;
; X32-BWON-LABEL: test4:
; X32-BWON: ## %bb.0: ## %entry
; X32-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
; X32-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-BWON-NEXT: movw %ax, 2(%ecx)
; X32-BWON-NEXT: retl
;
; X32-BWOFF-LABEL: test4:
; X32-BWOFF: ## %bb.0: ## %entry
; X32-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
; X32-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-BWOFF-NEXT: movw %ax, 2(%ecx)
; X32-BWOFF-NEXT: retl
entry:
%A = load i32, i32* %a0, align 4
%B = and i32 %A, 65535 ; 0x0000FFFF
%C = zext i16 %a1 to i32
%CS = shl i32 %C, 16
%D = or i32 %B, %CS
store i32 %D, i32* %a0, align 4
ret void
}
define void @test5(i64* nocapture %a0, i16 zeroext %a1) nounwind ssp {
; X64-LABEL: test5:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movw %si, 2(%rdi)
; X64-NEXT: retq
;
; X32-BWON-LABEL: test5:
; X32-BWON: ## %bb.0: ## %entry
; X32-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
; X32-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-BWON-NEXT: movw %ax, 2(%ecx)
; X32-BWON-NEXT: retl
;
; X32-BWOFF-LABEL: test5:
; X32-BWOFF: ## %bb.0: ## %entry
; X32-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
; X32-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-BWOFF-NEXT: movw %ax, 2(%ecx)
; X32-BWOFF-NEXT: retl
entry:
%A = load i64, i64* %a0, align 4
%B = and i64 %A, -4294901761 ; 0xFFFFFFFF0000FFFF
%C = zext i16 %a1 to i64
%CS = shl i64 %C, 16
%D = or i64 %B, %CS
store i64 %D, i64* %a0, align 4
ret void
}
define void @test6(i64* nocapture %a0, i8 zeroext %a1) nounwind ssp {
; X64-LABEL: test6:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movb %sil, 5(%rdi)
; X64-NEXT: retq
;
; X32-LABEL: test6:
; X32: ## %bb.0: ## %entry
; X32-NEXT: movb {{[0-9]+}}(%esp), %al
; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X32-NEXT: movb %al, 5(%ecx)
; X32-NEXT: retl
entry:
%A = load i64, i64* %a0, align 4
%B = and i64 %A, -280375465082881 ; 0xFFFF00FFFFFFFFFF
%C = zext i8 %a1 to i64
%CS = shl i64 %C, 40
%D = or i64 %B, %CS
store i64 %D, i64* %a0, align 4
ret void
}
define i32 @test7(i64* nocapture %a0, i8 zeroext %a1, i32* %P2) nounwind {
; X64-LABEL: test7:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movl (%rdx), %eax
; X64-NEXT: movb %sil, 5(%rdi)
; X64-NEXT: retq
;
; X32-LABEL: test7:
; X32: ## %bb.0: ## %entry
; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
; X32-NEXT: movl (%eax), %eax
; X32-NEXT: movb %cl, 5(%edx)
; X32-NEXT: retl
entry:
%OtherLoad = load i32 , i32 *%P2
%A = load i64, i64* %a0, align 4
%B = and i64 %A, -280375465082881 ; 0xFFFF00FFFFFFFFFF
%C = zext i8 %a1 to i64
%CS = shl i64 %C, 40
%D = or i64 %B, %CS
store i64 %D, i64* %a0, align 4
ret i32 %OtherLoad
}
; PR7833
@g_16 = internal global i32 -1
define void @test8() nounwind {
; X64-LABEL: test8:
; X64: ## %bb.0:
; X64-NEXT: orb $1, {{.*}}(%rip)
; X64-NEXT: retq
;
; X32-LABEL: test8:
; X32: ## %bb.0:
; X32-NEXT: orb $1, _g_16
; X32-NEXT: retl
%tmp = load i32, i32* @g_16
store i32 0, i32* @g_16
%or = or i32 %tmp, 1
store i32 %or, i32* @g_16
ret void
}
define void @test9() nounwind {
; X64-LABEL: test9:
; X64: ## %bb.0:
; X64-NEXT: orb $1, {{.*}}(%rip)
; X64-NEXT: retq
;
; X32-LABEL: test9:
; X32: ## %bb.0:
; X32-NEXT: orb $1, _g_16
; X32-NEXT: retl
%tmp = load i32, i32* @g_16
%or = or i32 %tmp, 1
store i32 %or, i32* @g_16
ret void
}
; rdar://8494845 + PR8244
define i8 @test10(i8* %P) nounwind ssp {
; X64-LABEL: test10:
; X64: ## %bb.0: ## %entry
; X64-NEXT: movsbl (%rdi), %eax
; X64-NEXT: shrl $8, %eax
; X64-NEXT: ## kill: def $al killed $al killed $eax
; X64-NEXT: retq
;
; X32-LABEL: test10:
; X32: ## %bb.0: ## %entry
; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
; X32-NEXT: movsbl (%eax), %eax
; X32-NEXT: movb %ah, %al
; X32-NEXT: retl
entry:
%tmp = load i8, i8* %P, align 1
%conv = sext i8 %tmp to i32
%shr3 = lshr i32 %conv, 8
%conv2 = trunc i32 %shr3 to i8
ret i8 %conv2
}