1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
3 ; RUN: llc -mtriple=x86_64-apple-darwin10.2 < %s | FileCheck %s -check-prefix=X64
4 ; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=1 < %s | FileCheck %s -check-prefix=X32 -check-prefix=X32-BWON
5 ; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=0 < %s | FileCheck %s -check-prefix=X32 -check-prefix=X32-BWOFF
6 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"
8 define void @test1(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
10 ; X64: ## %bb.0: ## %entry
11 ; X64-NEXT: movb %sil, (%rdi)
15 ; X32: ## %bb.0: ## %entry
16 ; X32-NEXT: movb {{[0-9]+}}(%esp), %al
17 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
18 ; X32-NEXT: movb %al, (%ecx)
21 %A = load i32, i32* %a0, align 4
22 %B = and i32 %A, -256 ; 0xFFFFFF00
23 %C = zext i8 %a1 to i32
25 store i32 %D, i32* %a0, align 4
29 define void @test2(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
31 ; X64: ## %bb.0: ## %entry
32 ; X64-NEXT: movb %sil, 1(%rdi)
36 ; X32: ## %bb.0: ## %entry
37 ; X32-NEXT: movb {{[0-9]+}}(%esp), %al
38 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
39 ; X32-NEXT: movb %al, 1(%ecx)
42 %A = load i32, i32* %a0, align 4
43 %B = and i32 %A, -65281 ; 0xFFFF00FF
44 %C = zext i8 %a1 to i32
47 store i32 %D, i32* %a0, align 4
51 define void @test3(i32* nocapture %a0, i16 zeroext %a1) nounwind ssp {
53 ; X64: ## %bb.0: ## %entry
54 ; X64-NEXT: movw %si, (%rdi)
57 ; X32-BWON-LABEL: test3:
58 ; X32-BWON: ## %bb.0: ## %entry
59 ; X32-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
60 ; X32-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
61 ; X32-BWON-NEXT: movw %ax, (%ecx)
64 ; X32-BWOFF-LABEL: test3:
65 ; X32-BWOFF: ## %bb.0: ## %entry
66 ; X32-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
67 ; X32-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
68 ; X32-BWOFF-NEXT: movw %ax, (%ecx)
69 ; X32-BWOFF-NEXT: retl
71 %A = load i32, i32* %a0, align 4
72 %B = and i32 %A, -65536 ; 0xFFFF0000
73 %C = zext i16 %a1 to i32
75 store i32 %D, i32* %a0, align 4
79 define void @test4(i32* nocapture %a0, i16 zeroext %a1) nounwind ssp {
81 ; X64: ## %bb.0: ## %entry
82 ; X64-NEXT: movw %si, 2(%rdi)
85 ; X32-BWON-LABEL: test4:
86 ; X32-BWON: ## %bb.0: ## %entry
87 ; X32-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
88 ; X32-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
89 ; X32-BWON-NEXT: movw %ax, 2(%ecx)
92 ; X32-BWOFF-LABEL: test4:
93 ; X32-BWOFF: ## %bb.0: ## %entry
94 ; X32-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
95 ; X32-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
96 ; X32-BWOFF-NEXT: movw %ax, 2(%ecx)
97 ; X32-BWOFF-NEXT: retl
99 %A = load i32, i32* %a0, align 4
100 %B = and i32 %A, 65535 ; 0x0000FFFF
101 %C = zext i16 %a1 to i32
104 store i32 %D, i32* %a0, align 4
108 define void @test5(i64* nocapture %a0, i16 zeroext %a1) nounwind ssp {
110 ; X64: ## %bb.0: ## %entry
111 ; X64-NEXT: movw %si, 2(%rdi)
114 ; X32-BWON-LABEL: test5:
115 ; X32-BWON: ## %bb.0: ## %entry
116 ; X32-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
117 ; X32-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
118 ; X32-BWON-NEXT: movw %ax, 2(%ecx)
119 ; X32-BWON-NEXT: retl
121 ; X32-BWOFF-LABEL: test5:
122 ; X32-BWOFF: ## %bb.0: ## %entry
123 ; X32-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
124 ; X32-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
125 ; X32-BWOFF-NEXT: movw %ax, 2(%ecx)
126 ; X32-BWOFF-NEXT: retl
128 %A = load i64, i64* %a0, align 4
129 %B = and i64 %A, -4294901761 ; 0xFFFFFFFF0000FFFF
130 %C = zext i16 %a1 to i64
133 store i64 %D, i64* %a0, align 4
137 define void @test6(i64* nocapture %a0, i8 zeroext %a1) nounwind ssp {
139 ; X64: ## %bb.0: ## %entry
140 ; X64-NEXT: movb %sil, 5(%rdi)
144 ; X32: ## %bb.0: ## %entry
145 ; X32-NEXT: movb {{[0-9]+}}(%esp), %al
146 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
147 ; X32-NEXT: movb %al, 5(%ecx)
150 %A = load i64, i64* %a0, align 4
151 %B = and i64 %A, -280375465082881 ; 0xFFFF00FFFFFFFFFF
152 %C = zext i8 %a1 to i64
155 store i64 %D, i64* %a0, align 4
159 define i32 @test7(i64* nocapture %a0, i8 zeroext %a1, i32* %P2) nounwind {
161 ; X64: ## %bb.0: ## %entry
162 ; X64-NEXT: movl (%rdx), %eax
163 ; X64-NEXT: movb %sil, 5(%rdi)
167 ; X32: ## %bb.0: ## %entry
168 ; X32-NEXT: movb {{[0-9]+}}(%esp), %cl
169 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
170 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
171 ; X32-NEXT: movl (%eax), %eax
172 ; X32-NEXT: movb %cl, 5(%edx)
175 %OtherLoad = load i32 , i32 *%P2
176 %A = load i64, i64* %a0, align 4
177 %B = and i64 %A, -280375465082881 ; 0xFFFF00FFFFFFFFFF
178 %C = zext i8 %a1 to i64
181 store i64 %D, i64* %a0, align 4
187 @g_16 = internal global i32 -1
189 define void @test8() nounwind {
192 ; X64-NEXT: orb $1, {{.*}}(%rip)
197 ; X32-NEXT: orb $1, _g_16
199 %tmp = load i32, i32* @g_16
200 store i32 0, i32* @g_16
202 store i32 %or, i32* @g_16
206 define void @test9() nounwind {
209 ; X64-NEXT: orb $1, {{.*}}(%rip)
214 ; X32-NEXT: orb $1, _g_16
216 %tmp = load i32, i32* @g_16
218 store i32 %or, i32* @g_16
222 ; rdar://8494845 + PR8244
223 define i8 @test10(i8* %P) nounwind ssp {
225 ; X64: ## %bb.0: ## %entry
226 ; X64-NEXT: movsbl (%rdi), %eax
227 ; X64-NEXT: shrl $8, %eax
228 ; X64-NEXT: ## kill: def $al killed $al killed $eax
232 ; X32: ## %bb.0: ## %entry
233 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
234 ; X32-NEXT: movsbl (%eax), %eax
235 ; X32-NEXT: movb %ah, %al
238 %tmp = load i8, i8* %P, align 1
239 %conv = sext i8 %tmp to i32
240 %shr3 = lshr i32 %conv, 8
241 %conv2 = trunc i32 %shr3 to i8