• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-darwin-unknown < %s | FileCheck %s --check-prefix=X64
3; RUN: llc -mtriple=i686-darwin-unknown < %s | FileCheck %s --check-prefix=X86
4
5define zeroext i1 @saddoi128(i128 %v1, i128 %v2, i128* %res) nounwind {
6; X64-LABEL: saddoi128:
7; X64:       ## %bb.0:
8; X64-NEXT:    addq %rdx, %rdi
9; X64-NEXT:    adcq %rcx, %rsi
10; X64-NEXT:    seto %al
11; X64-NEXT:    movq %rdi, (%r8)
12; X64-NEXT:    movq %rsi, 8(%r8)
13; X64-NEXT:    retq
14;
15; X86-LABEL: saddoi128:
16; X86:       ## %bb.0:
17; X86-NEXT:    pushl %ebx
18; X86-NEXT:    pushl %edi
19; X86-NEXT:    pushl %esi
20; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
21; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
22; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
23; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
24; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
25; X86-NEXT:    addl {{[0-9]+}}(%esp), %edi
26; X86-NEXT:    adcl {{[0-9]+}}(%esp), %ebx
27; X86-NEXT:    adcl {{[0-9]+}}(%esp), %esi
28; X86-NEXT:    adcl {{[0-9]+}}(%esp), %edx
29; X86-NEXT:    seto %al
30; X86-NEXT:    movl %edi, (%ecx)
31; X86-NEXT:    movl %ebx, 4(%ecx)
32; X86-NEXT:    movl %esi, 8(%ecx)
33; X86-NEXT:    movl %edx, 12(%ecx)
34; X86-NEXT:    popl %esi
35; X86-NEXT:    popl %edi
36; X86-NEXT:    popl %ebx
37; X86-NEXT:    retl
38  %t = call {i128, i1} @llvm.sadd.with.overflow.i128(i128 %v1, i128 %v2)
39  %val = extractvalue {i128, i1} %t, 0
40  %obit = extractvalue {i128, i1} %t, 1
41  store i128 %val, i128* %res
42  ret i1 %obit
43}
44
45define zeroext i1 @uaddoi128(i128 %v1, i128 %v2, i128* %res) nounwind {
46; X64-LABEL: uaddoi128:
47; X64:       ## %bb.0:
48; X64-NEXT:    addq %rdx, %rdi
49; X64-NEXT:    adcq %rcx, %rsi
50; X64-NEXT:    setb %al
51; X64-NEXT:    movq %rdi, (%r8)
52; X64-NEXT:    movq %rsi, 8(%r8)
53; X64-NEXT:    retq
54;
55; X86-LABEL: uaddoi128:
56; X86:       ## %bb.0:
57; X86-NEXT:    pushl %ebx
58; X86-NEXT:    pushl %edi
59; X86-NEXT:    pushl %esi
60; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
61; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
62; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
63; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
64; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
65; X86-NEXT:    addl {{[0-9]+}}(%esp), %edi
66; X86-NEXT:    adcl {{[0-9]+}}(%esp), %ebx
67; X86-NEXT:    adcl {{[0-9]+}}(%esp), %esi
68; X86-NEXT:    adcl {{[0-9]+}}(%esp), %edx
69; X86-NEXT:    setb %al
70; X86-NEXT:    movl %edi, (%ecx)
71; X86-NEXT:    movl %ebx, 4(%ecx)
72; X86-NEXT:    movl %esi, 8(%ecx)
73; X86-NEXT:    movl %edx, 12(%ecx)
74; X86-NEXT:    popl %esi
75; X86-NEXT:    popl %edi
76; X86-NEXT:    popl %ebx
77; X86-NEXT:    retl
78  %t = call {i128, i1} @llvm.uadd.with.overflow.i128(i128 %v1, i128 %v2)
79  %val = extractvalue {i128, i1} %t, 0
80  %obit = extractvalue {i128, i1} %t, 1
81  store i128 %val, i128* %res
82  ret i1 %obit
83}
84
85
86define zeroext i1 @ssuboi128(i128 %v1, i128 %v2, i128* %res) nounwind {
87; X64-LABEL: ssuboi128:
88; X64:       ## %bb.0:
89; X64-NEXT:    subq %rdx, %rdi
90; X64-NEXT:    sbbq %rcx, %rsi
91; X64-NEXT:    seto %al
92; X64-NEXT:    movq %rdi, (%r8)
93; X64-NEXT:    movq %rsi, 8(%r8)
94; X64-NEXT:    retq
95;
96; X86-LABEL: ssuboi128:
97; X86:       ## %bb.0:
98; X86-NEXT:    pushl %ebx
99; X86-NEXT:    pushl %edi
100; X86-NEXT:    pushl %esi
101; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
102; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
103; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
104; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
105; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
106; X86-NEXT:    subl {{[0-9]+}}(%esp), %edi
107; X86-NEXT:    sbbl {{[0-9]+}}(%esp), %ebx
108; X86-NEXT:    sbbl {{[0-9]+}}(%esp), %esi
109; X86-NEXT:    sbbl {{[0-9]+}}(%esp), %edx
110; X86-NEXT:    seto %al
111; X86-NEXT:    movl %edi, (%ecx)
112; X86-NEXT:    movl %ebx, 4(%ecx)
113; X86-NEXT:    movl %esi, 8(%ecx)
114; X86-NEXT:    movl %edx, 12(%ecx)
115; X86-NEXT:    popl %esi
116; X86-NEXT:    popl %edi
117; X86-NEXT:    popl %ebx
118; X86-NEXT:    retl
119  %t = call {i128, i1} @llvm.ssub.with.overflow.i128(i128 %v1, i128 %v2)
120  %val = extractvalue {i128, i1} %t, 0
121  %obit = extractvalue {i128, i1} %t, 1
122  store i128 %val, i128* %res
123  ret i1 %obit
124}
125
126define zeroext i1 @usuboi128(i128 %v1, i128 %v2, i128* %res) nounwind {
127; X64-LABEL: usuboi128:
128; X64:       ## %bb.0:
129; X64-NEXT:    subq %rdx, %rdi
130; X64-NEXT:    sbbq %rcx, %rsi
131; X64-NEXT:    setb %al
132; X64-NEXT:    movq %rdi, (%r8)
133; X64-NEXT:    movq %rsi, 8(%r8)
134; X64-NEXT:    retq
135;
136; X86-LABEL: usuboi128:
137; X86:       ## %bb.0:
138; X86-NEXT:    pushl %ebx
139; X86-NEXT:    pushl %edi
140; X86-NEXT:    pushl %esi
141; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
142; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
143; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
144; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
145; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
146; X86-NEXT:    subl {{[0-9]+}}(%esp), %edi
147; X86-NEXT:    sbbl {{[0-9]+}}(%esp), %ebx
148; X86-NEXT:    sbbl {{[0-9]+}}(%esp), %esi
149; X86-NEXT:    sbbl {{[0-9]+}}(%esp), %edx
150; X86-NEXT:    setb %al
151; X86-NEXT:    movl %edi, (%ecx)
152; X86-NEXT:    movl %ebx, 4(%ecx)
153; X86-NEXT:    movl %esi, 8(%ecx)
154; X86-NEXT:    movl %edx, 12(%ecx)
155; X86-NEXT:    popl %esi
156; X86-NEXT:    popl %edi
157; X86-NEXT:    popl %ebx
158; X86-NEXT:    retl
159  %t = call {i128, i1} @llvm.usub.with.overflow.i128(i128 %v1, i128 %v2)
160  %val = extractvalue {i128, i1} %t, 0
161  %obit = extractvalue {i128, i1} %t, 1
162  store i128 %val, i128* %res
163  ret i1 %obit
164}
165
166declare {i128, i1} @llvm.sadd.with.overflow.i128(i128, i128) nounwind readnone
167declare {i128, i1} @llvm.uadd.with.overflow.i128(i128, i128) nounwind readnone
168declare {i128, i1} @llvm.ssub.with.overflow.i128(i128, i128) nounwind readnone
169declare {i128, i1} @llvm.usub.with.overflow.i128(i128, i128) nounwind readnone
170