1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-apple-darwin10.2 < %s | FileCheck %s -check-prefix=X64
3 ; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=1 < %s | FileCheck %s -check-prefixes=X86,X86-BWON
4 ; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=0 < %s | FileCheck %s -check-prefixes=X86,X86-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"
10 define void @test1(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
12 ; X64: ## %bb.0: ## %entry
13 ; X64-NEXT: movb %sil, (%rdi)
17 ; X86: ## %bb.0: ## %entry
18 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
19 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
20 ; X86-NEXT: movb %al, (%ecx)
23 %A = load i32, i32* %a0, align 4
24 %B = and i32 %A, -256 ; 0xFFFFFF00
25 %C = zext i8 %a1 to i32
27 store i32 %D, i32* %a0, align 4
31 define void @test2(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
33 ; X64: ## %bb.0: ## %entry
34 ; X64-NEXT: movb %sil, 1(%rdi)
38 ; X86: ## %bb.0: ## %entry
39 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
40 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
41 ; X86-NEXT: movb %al, 1(%ecx)
44 %A = load i32, i32* %a0, align 4
45 %B = and i32 %A, -65281 ; 0xFFFF00FF
46 %C = zext i8 %a1 to i32
49 store i32 %D, i32* %a0, align 4
53 define void @test3(i32* nocapture %a0, i16 zeroext %a1) nounwind ssp {
55 ; X64: ## %bb.0: ## %entry
56 ; X64-NEXT: movw %si, (%rdi)
59 ; X86-BWON-LABEL: test3:
60 ; X86-BWON: ## %bb.0: ## %entry
61 ; X86-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
62 ; X86-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
63 ; X86-BWON-NEXT: movw %ax, (%ecx)
66 ; X86-BWOFF-LABEL: test3:
67 ; X86-BWOFF: ## %bb.0: ## %entry
68 ; X86-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
69 ; X86-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
70 ; X86-BWOFF-NEXT: movw %ax, (%ecx)
71 ; X86-BWOFF-NEXT: retl
73 %A = load i32, i32* %a0, align 4
74 %B = and i32 %A, -65536 ; 0xFFFF0000
75 %C = zext i16 %a1 to i32
77 store i32 %D, i32* %a0, align 4
81 define void @test4(i32* nocapture %a0, i16 zeroext %a1) nounwind ssp {
83 ; X64: ## %bb.0: ## %entry
84 ; X64-NEXT: movw %si, 2(%rdi)
87 ; X86-BWON-LABEL: test4:
88 ; X86-BWON: ## %bb.0: ## %entry
89 ; X86-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
90 ; X86-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
91 ; X86-BWON-NEXT: movw %ax, 2(%ecx)
94 ; X86-BWOFF-LABEL: test4:
95 ; X86-BWOFF: ## %bb.0: ## %entry
96 ; X86-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
97 ; X86-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
98 ; X86-BWOFF-NEXT: movw %ax, 2(%ecx)
99 ; X86-BWOFF-NEXT: retl
101 %A = load i32, i32* %a0, align 4
102 %B = and i32 %A, 65535 ; 0x0000FFFF
103 %C = zext i16 %a1 to i32
106 store i32 %D, i32* %a0, align 4
110 define void @test5(i64* nocapture %a0, i16 zeroext %a1) nounwind ssp {
112 ; X64: ## %bb.0: ## %entry
113 ; X64-NEXT: movw %si, 2(%rdi)
116 ; X86-BWON-LABEL: test5:
117 ; X86-BWON: ## %bb.0: ## %entry
118 ; X86-BWON-NEXT: movzwl {{[0-9]+}}(%esp), %eax
119 ; X86-BWON-NEXT: movl {{[0-9]+}}(%esp), %ecx
120 ; X86-BWON-NEXT: movw %ax, 2(%ecx)
121 ; X86-BWON-NEXT: retl
123 ; X86-BWOFF-LABEL: test5:
124 ; X86-BWOFF: ## %bb.0: ## %entry
125 ; X86-BWOFF-NEXT: movw {{[0-9]+}}(%esp), %ax
126 ; X86-BWOFF-NEXT: movl {{[0-9]+}}(%esp), %ecx
127 ; X86-BWOFF-NEXT: movw %ax, 2(%ecx)
128 ; X86-BWOFF-NEXT: retl
130 %A = load i64, i64* %a0, align 4
131 %B = and i64 %A, -4294901761 ; 0xFFFFFFFF0000FFFF
132 %C = zext i16 %a1 to i64
135 store i64 %D, i64* %a0, align 4
139 define void @test6(i64* nocapture %a0, i8 zeroext %a1) nounwind ssp {
141 ; X64: ## %bb.0: ## %entry
142 ; X64-NEXT: movb %sil, 5(%rdi)
146 ; X86: ## %bb.0: ## %entry
147 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
148 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
149 ; X86-NEXT: movb %al, 5(%ecx)
152 %A = load i64, i64* %a0, align 4
153 %B = and i64 %A, -280375465082881 ; 0xFFFF00FFFFFFFFFF
154 %C = zext i8 %a1 to i64
157 store i64 %D, i64* %a0, align 4
161 define i32 @test7(i64* nocapture %a0, i8 zeroext %a1, i32* %P2) nounwind {
163 ; X64: ## %bb.0: ## %entry
164 ; X64-NEXT: movl (%rdx), %eax
165 ; X64-NEXT: movb %sil, 5(%rdi)
169 ; X86: ## %bb.0: ## %entry
170 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
171 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
172 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
173 ; X86-NEXT: movl (%eax), %eax
174 ; X86-NEXT: movb %cl, 5(%edx)
177 %OtherLoad = load i32 , i32 *%P2
178 %A = load i64, i64* %a0, align 4
179 %B = and i64 %A, -280375465082881 ; 0xFFFF00FFFFFFFFFF
180 %C = zext i8 %a1 to i64
183 store i64 %D, i64* %a0, align 4
189 @g_16 = internal global i32 -1
191 define void @test8() nounwind {
194 ; X64-NEXT: orb $1, _g_16(%rip)
199 ; X86-NEXT: orb $1, _g_16
201 %tmp = load i32, i32* @g_16
202 store i32 0, i32* @g_16
204 store i32 %or, i32* @g_16
208 define void @test9() nounwind {
211 ; X64-NEXT: orb $1, _g_16(%rip)
216 ; X86-NEXT: orb $1, _g_16
218 %tmp = load i32, i32* @g_16
220 store i32 %or, i32* @g_16
224 ; rdar://8494845 + PR8244
225 define i8 @test10(i8* %P) nounwind ssp {
227 ; X64: ## %bb.0: ## %entry
228 ; X64-NEXT: movsbl (%rdi), %eax
229 ; X64-NEXT: shrl $8, %eax
230 ; X64-NEXT: ## kill: def $al killed $al killed $eax
234 ; X86: ## %bb.0: ## %entry
235 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
236 ; X86-NEXT: movsbl (%eax), %eax
237 ; X86-NEXT: movb %ah, %al
240 %tmp = load i8, i8* %P, align 1
241 %conv = sext i8 %tmp to i32
242 %shr3 = lshr i32 %conv, 8
243 %conv2 = trunc i32 %shr3 to i8