1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=X86-64 3; RUN: llc < %s -mtriple=x86_64-cygwin | FileCheck %s -check-prefix=WIN64 4; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s -check-prefix=WIN64 5; RUN: llc < %s -mtriple=x86_64-mingw32 | FileCheck %s -check-prefix=WIN64 6 7define i64 @mod128(i128 %x) nounwind { 8; X86-64-LABEL: mod128: 9; X86-64: # %bb.0: 10; X86-64-NEXT: pushq %rax 11; X86-64-NEXT: movl $3, %edx 12; X86-64-NEXT: xorl %ecx, %ecx 13; X86-64-NEXT: callq __modti3 14; X86-64-NEXT: popq %rcx 15; X86-64-NEXT: retq 16; 17; WIN64-LABEL: mod128: 18; WIN64: # %bb.0: 19; WIN64-NEXT: subq $72, %rsp 20; WIN64-NEXT: movq %rdx, {{[0-9]+}}(%rsp) 21; WIN64-NEXT: movq %rcx, {{[0-9]+}}(%rsp) 22; WIN64-NEXT: movq $3, {{[0-9]+}}(%rsp) 23; WIN64-NEXT: movq $0, {{[0-9]+}}(%rsp) 24; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rcx 25; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rdx 26; WIN64-NEXT: callq __modti3 27; WIN64-NEXT: movq %xmm0, %rax 28; WIN64-NEXT: addq $72, %rsp 29; WIN64-NEXT: retq 30 31 32 %1 = srem i128 %x, 3 33 %2 = trunc i128 %1 to i64 34 ret i64 %2 35} 36 37define i64 @div128(i128 %x) nounwind { 38; X86-64-LABEL: div128: 39; X86-64: # %bb.0: 40; X86-64-NEXT: pushq %rax 41; X86-64-NEXT: movl $3, %edx 42; X86-64-NEXT: xorl %ecx, %ecx 43; X86-64-NEXT: callq __divti3 44; X86-64-NEXT: popq %rcx 45; X86-64-NEXT: retq 46; 47; WIN64-LABEL: div128: 48; WIN64: # %bb.0: 49; WIN64-NEXT: subq $72, %rsp 50; WIN64-NEXT: movq %rdx, {{[0-9]+}}(%rsp) 51; WIN64-NEXT: movq %rcx, {{[0-9]+}}(%rsp) 52; WIN64-NEXT: movq $3, {{[0-9]+}}(%rsp) 53; WIN64-NEXT: movq $0, {{[0-9]+}}(%rsp) 54; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rcx 55; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rdx 56; WIN64-NEXT: callq __divti3 57; WIN64-NEXT: movq %xmm0, %rax 58; WIN64-NEXT: addq $72, %rsp 59; WIN64-NEXT: retq 60 61 62 %1 = sdiv i128 %x, 3 63 %2 = trunc i128 %1 to i64 64 ret i64 %2 65} 66 67define i64 @umod128(i128 %x) nounwind { 68; X86-64-LABEL: umod128: 69; X86-64: # %bb.0: 70; X86-64-NEXT: pushq %rax 71; X86-64-NEXT: movl $3, %edx 72; X86-64-NEXT: xorl %ecx, %ecx 73; X86-64-NEXT: callq __umodti3 74; X86-64-NEXT: popq %rcx 75; X86-64-NEXT: retq 76; 77; WIN64-LABEL: umod128: 78; WIN64: # %bb.0: 79; WIN64-NEXT: subq $72, %rsp 80; WIN64-NEXT: movq %rdx, {{[0-9]+}}(%rsp) 81; WIN64-NEXT: movq %rcx, {{[0-9]+}}(%rsp) 82; WIN64-NEXT: movq $3, {{[0-9]+}}(%rsp) 83; WIN64-NEXT: movq $0, {{[0-9]+}}(%rsp) 84; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rcx 85; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rdx 86; WIN64-NEXT: callq __umodti3 87; WIN64-NEXT: movq %xmm0, %rax 88; WIN64-NEXT: addq $72, %rsp 89; WIN64-NEXT: retq 90 91 92 %1 = urem i128 %x, 3 93 %2 = trunc i128 %1 to i64 94 ret i64 %2 95} 96 97define i64 @udiv128(i128 %x) nounwind { 98; X86-64-LABEL: udiv128: 99; X86-64: # %bb.0: 100; X86-64-NEXT: pushq %rax 101; X86-64-NEXT: movl $3, %edx 102; X86-64-NEXT: xorl %ecx, %ecx 103; X86-64-NEXT: callq __udivti3 104; X86-64-NEXT: popq %rcx 105; X86-64-NEXT: retq 106; 107; WIN64-LABEL: udiv128: 108; WIN64: # %bb.0: 109; WIN64-NEXT: subq $72, %rsp 110; WIN64-NEXT: movq %rdx, {{[0-9]+}}(%rsp) 111; WIN64-NEXT: movq %rcx, {{[0-9]+}}(%rsp) 112; WIN64-NEXT: movq $3, {{[0-9]+}}(%rsp) 113; WIN64-NEXT: movq $0, {{[0-9]+}}(%rsp) 114; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rcx 115; WIN64-NEXT: leaq {{[0-9]+}}(%rsp), %rdx 116; WIN64-NEXT: callq __udivti3 117; WIN64-NEXT: movq %xmm0, %rax 118; WIN64-NEXT: addq $72, %rsp 119; WIN64-NEXT: retq 120 121 122 %1 = udiv i128 %x, 3 123 %2 = trunc i128 %1 to i64 124 ret i64 %2 125} 126