1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2 ; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X32 3 ; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64 4 5 define void @si64(i64 %x, i64 %y, i64* %p, i64* %q) nounwind { 6 ; X32-LABEL: si64: 7 ; X32: # %bb.0: 8 ; X32-NEXT: pushl %ebp 9 ; X32-NEXT: pushl %ebx 10 ; X32-NEXT: pushl %edi 11 ; X32-NEXT: pushl %esi 12 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ebx 13 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ebp 14 ; X32-NEXT: pushl %ebp 15 ; X32-NEXT: pushl %ebx 16 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 17 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 18 ; X32-NEXT: calll __divdi3 19 ; X32-NEXT: addl $16, %esp 20 ; X32-NEXT: movl %eax, %esi 21 ; X32-NEXT: movl %edx, %edi 22 ; X32-NEXT: pushl %ebp 23 ; X32-NEXT: pushl %ebx 24 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 25 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 26 ; X32-NEXT: calll __moddi3 27 ; X32-NEXT: addl $16, %esp 28 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 29 ; X32-NEXT: movl %edi, 4(%ecx) 30 ; X32-NEXT: movl %esi, (%ecx) 31 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 32 ; X32-NEXT: movl %edx, 4(%ecx) 33 ; X32-NEXT: movl %eax, (%ecx) 34 ; X32-NEXT: popl %esi 35 ; X32-NEXT: popl %edi 36 ; X32-NEXT: popl %ebx 37 ; X32-NEXT: popl %ebp 38 ; X32-NEXT: retl 39 ; 40 ; X64-LABEL: si64: 41 ; X64: # %bb.0: 42 ; X64-NEXT: movq %rdx, %r8 43 ; X64-NEXT: movq %rdi, %rax 44 ; X64-NEXT: cqto 45 ; X64-NEXT: idivq %rsi 46 ; X64-NEXT: movq %rax, (%r8) 47 ; X64-NEXT: movq %rdx, (%rcx) 48 ; X64-NEXT: retq 49 %r = sdiv i64 %x, %y 50 %t = srem i64 %x, %y 51 store i64 %r, i64* %p 52 store i64 %t, i64* %q 53 ret void 54 } 55 56 define void @si32(i32 %x, i32 %y, i32* %p, i32* %q) nounwind { 57 ; X32-LABEL: si32: 58 ; X32: # %bb.0: 59 ; X32-NEXT: pushl %esi 60 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 61 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi 62 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 63 ; X32-NEXT: cltd 64 ; X32-NEXT: idivl {{[0-9]+}}(%esp) 65 ; X32-NEXT: movl %eax, (%esi) 66 ; X32-NEXT: movl %edx, (%ecx) 67 ; X32-NEXT: popl %esi 68 ; X32-NEXT: retl 69 ; 70 ; X64-LABEL: si32: 71 ; X64: # %bb.0: 72 ; X64-NEXT: movq %rdx, %r8 73 ; X64-NEXT: movl %edi, %eax 74 ; X64-NEXT: cltd 75 ; X64-NEXT: idivl %esi 76 ; X64-NEXT: movl %eax, (%r8) 77 ; X64-NEXT: movl %edx, (%rcx) 78 ; X64-NEXT: retq 79 %r = sdiv i32 %x, %y 80 %t = srem i32 %x, %y 81 store i32 %r, i32* %p 82 store i32 %t, i32* %q 83 ret void 84 } 85 86 define void @si16(i16 %x, i16 %y, i16* %p, i16* %q) nounwind { 87 ; X32-LABEL: si16: 88 ; X32: # %bb.0: 89 ; X32-NEXT: pushl %esi 90 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 91 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi 92 ; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax 93 ; X32-NEXT: cwtd 94 ; X32-NEXT: idivw {{[0-9]+}}(%esp) 95 ; X32-NEXT: movw %ax, (%esi) 96 ; X32-NEXT: movw %dx, (%ecx) 97 ; X32-NEXT: popl %esi 98 ; X32-NEXT: retl 99 ; 100 ; X64-LABEL: si16: 101 ; X64: # %bb.0: 102 ; X64-NEXT: movq %rdx, %r8 103 ; X64-NEXT: movl %edi, %eax 104 ; X64-NEXT: cwtd 105 ; X64-NEXT: idivw %si 106 ; X64-NEXT: movw %ax, (%r8) 107 ; X64-NEXT: movw %dx, (%rcx) 108 ; X64-NEXT: retq 109 %r = sdiv i16 %x, %y 110 %t = srem i16 %x, %y 111 store i16 %r, i16* %p 112 store i16 %t, i16* %q 113 ret void 114 } 115 116 define void @si8(i8 %x, i8 %y, i8* %p, i8* %q) nounwind { 117 ; X32-LABEL: si8: 118 ; X32: # %bb.0: 119 ; X32-NEXT: pushl %ebx 120 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 121 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx 122 ; X32-NEXT: movb {{[0-9]+}}(%esp), %al 123 ; X32-NEXT: cbtw 124 ; X32-NEXT: idivb {{[0-9]+}}(%esp) 125 ; X32-NEXT: movsbl %ah, %ebx 126 ; X32-NEXT: movb %al, (%edx) 127 ; X32-NEXT: movb %bl, (%ecx) 128 ; X32-NEXT: popl %ebx 129 ; X32-NEXT: retl 130 ; 131 ; X64-LABEL: si8: 132 ; X64: # %bb.0: 133 ; X64-NEXT: movl %edi, %eax 134 ; X64-NEXT: cbtw 135 ; X64-NEXT: idivb %sil 136 ; X64-NEXT: movsbl %ah, %esi 137 ; X64-NEXT: movb %al, (%rdx) 138 ; X64-NEXT: movb %sil, (%rcx) 139 ; X64-NEXT: retq 140 %r = sdiv i8 %x, %y 141 %t = srem i8 %x, %y 142 store i8 %r, i8* %p 143 store i8 %t, i8* %q 144 ret void 145 } 146 147 define void @ui64(i64 %x, i64 %y, i64* %p, i64* %q) nounwind { 148 ; X32-LABEL: ui64: 149 ; X32: # %bb.0: 150 ; X32-NEXT: pushl %ebp 151 ; X32-NEXT: pushl %ebx 152 ; X32-NEXT: pushl %edi 153 ; X32-NEXT: pushl %esi 154 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ebx 155 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ebp 156 ; X32-NEXT: pushl %ebp 157 ; X32-NEXT: pushl %ebx 158 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 159 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 160 ; X32-NEXT: calll __udivdi3 161 ; X32-NEXT: addl $16, %esp 162 ; X32-NEXT: movl %eax, %esi 163 ; X32-NEXT: movl %edx, %edi 164 ; X32-NEXT: pushl %ebp 165 ; X32-NEXT: pushl %ebx 166 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 167 ; X32-NEXT: pushl {{[0-9]+}}(%esp) 168 ; X32-NEXT: calll __umoddi3 169 ; X32-NEXT: addl $16, %esp 170 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 171 ; X32-NEXT: movl %edi, 4(%ecx) 172 ; X32-NEXT: movl %esi, (%ecx) 173 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 174 ; X32-NEXT: movl %edx, 4(%ecx) 175 ; X32-NEXT: movl %eax, (%ecx) 176 ; X32-NEXT: popl %esi 177 ; X32-NEXT: popl %edi 178 ; X32-NEXT: popl %ebx 179 ; X32-NEXT: popl %ebp 180 ; X32-NEXT: retl 181 ; 182 ; X64-LABEL: ui64: 183 ; X64: # %bb.0: 184 ; X64-NEXT: movq %rdx, %r8 185 ; X64-NEXT: xorl %edx, %edx 186 ; X64-NEXT: movq %rdi, %rax 187 ; X64-NEXT: divq %rsi 188 ; X64-NEXT: movq %rax, (%r8) 189 ; X64-NEXT: movq %rdx, (%rcx) 190 ; X64-NEXT: retq 191 %r = udiv i64 %x, %y 192 %t = urem i64 %x, %y 193 store i64 %r, i64* %p 194 store i64 %t, i64* %q 195 ret void 196 } 197 198 define void @ui32(i32 %x, i32 %y, i32* %p, i32* %q) nounwind { 199 ; X32-LABEL: ui32: 200 ; X32: # %bb.0: 201 ; X32-NEXT: pushl %esi 202 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 203 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi 204 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 205 ; X32-NEXT: xorl %edx, %edx 206 ; X32-NEXT: divl {{[0-9]+}}(%esp) 207 ; X32-NEXT: movl %eax, (%esi) 208 ; X32-NEXT: movl %edx, (%ecx) 209 ; X32-NEXT: popl %esi 210 ; X32-NEXT: retl 211 ; 212 ; X64-LABEL: ui32: 213 ; X64: # %bb.0: 214 ; X64-NEXT: movq %rdx, %r8 215 ; X64-NEXT: xorl %edx, %edx 216 ; X64-NEXT: movl %edi, %eax 217 ; X64-NEXT: divl %esi 218 ; X64-NEXT: movl %eax, (%r8) 219 ; X64-NEXT: movl %edx, (%rcx) 220 ; X64-NEXT: retq 221 %r = udiv i32 %x, %y 222 %t = urem i32 %x, %y 223 store i32 %r, i32* %p 224 store i32 %t, i32* %q 225 ret void 226 } 227 228 define void @ui16(i16 %x, i16 %y, i16* %p, i16* %q) nounwind { 229 ; X32-LABEL: ui16: 230 ; X32: # %bb.0: 231 ; X32-NEXT: pushl %esi 232 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 233 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi 234 ; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax 235 ; X32-NEXT: xorl %edx, %edx 236 ; X32-NEXT: divw {{[0-9]+}}(%esp) 237 ; X32-NEXT: movw %ax, (%esi) 238 ; X32-NEXT: movw %dx, (%ecx) 239 ; X32-NEXT: popl %esi 240 ; X32-NEXT: retl 241 ; 242 ; X64-LABEL: ui16: 243 ; X64: # %bb.0: 244 ; X64-NEXT: movq %rdx, %r8 245 ; X64-NEXT: xorl %edx, %edx 246 ; X64-NEXT: movl %edi, %eax 247 ; X64-NEXT: divw %si 248 ; X64-NEXT: movw %ax, (%r8) 249 ; X64-NEXT: movw %dx, (%rcx) 250 ; X64-NEXT: retq 251 %r = udiv i16 %x, %y 252 %t = urem i16 %x, %y 253 store i16 %r, i16* %p 254 store i16 %t, i16* %q 255 ret void 256 } 257 258 define void @ui8(i8 %x, i8 %y, i8* %p, i8* %q) nounwind { 259 ; X32-LABEL: ui8: 260 ; X32: # %bb.0: 261 ; X32-NEXT: pushl %ebx 262 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 263 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx 264 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax 265 ; X32-NEXT: # kill: def $eax killed $eax def $ax 266 ; X32-NEXT: divb {{[0-9]+}}(%esp) 267 ; X32-NEXT: movzbl %ah, %ebx 268 ; X32-NEXT: movb %al, (%edx) 269 ; X32-NEXT: movb %bl, (%ecx) 270 ; X32-NEXT: popl %ebx 271 ; X32-NEXT: retl 272 ; 273 ; X64-LABEL: ui8: 274 ; X64: # %bb.0: 275 ; X64-NEXT: movzbl %dil, %eax 276 ; X64-NEXT: # kill: def $eax killed $eax def $ax 277 ; X64-NEXT: divb %sil 278 ; X64-NEXT: movzbl %ah, %esi 279 ; X64-NEXT: movb %al, (%rdx) 280 ; X64-NEXT: movb %sil, (%rcx) 281 ; X64-NEXT: retq 282 %r = udiv i8 %x, %y 283 %t = urem i8 %x, %y 284 store i8 %r, i8* %p 285 store i8 %t, i8* %q 286 ret void 287 } 288