• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
4
5declare i4 @llvm.sadd.sat.i4(i4, i4)
6declare i8 @llvm.sadd.sat.i8(i8, i8)
7declare i16 @llvm.sadd.sat.i16(i16, i16)
8declare i32 @llvm.sadd.sat.i32(i32, i32)
9declare i64 @llvm.sadd.sat.i64(i64, i64)
10
11define i32 @func32(i32 %x, i32 %y, i32 %z) nounwind {
12; X86-LABEL: func32:
13; X86:       # %bb.0:
14; X86-NEXT:    pushl %esi
15; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
16; X86-NEXT:    imull {{[0-9]+}}(%esp), %eax
17; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
18; X86-NEXT:    xorl %ecx, %ecx
19; X86-NEXT:    movl %eax, %esi
20; X86-NEXT:    addl %edx, %esi
21; X86-NEXT:    setns %cl
22; X86-NEXT:    addl $2147483647, %ecx # imm = 0x7FFFFFFF
23; X86-NEXT:    addl %edx, %eax
24; X86-NEXT:    cmovol %ecx, %eax
25; X86-NEXT:    popl %esi
26; X86-NEXT:    retl
27;
28; X64-LABEL: func32:
29; X64:       # %bb.0:
30; X64-NEXT:    imull %edx, %esi
31; X64-NEXT:    xorl %eax, %eax
32; X64-NEXT:    movl %edi, %ecx
33; X64-NEXT:    addl %esi, %ecx
34; X64-NEXT:    setns %al
35; X64-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
36; X64-NEXT:    addl %edi, %esi
37; X64-NEXT:    cmovnol %esi, %eax
38; X64-NEXT:    retq
39  %a = mul i32 %y, %z
40  %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %a)
41  ret i32 %tmp
42}
43
44define i64 @func64(i64 %x, i64 %y, i64 %z) nounwind {
45; X86-LABEL: func64:
46; X86:       # %bb.0:
47; X86-NEXT:    pushl %ebx
48; X86-NEXT:    pushl %esi
49; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
50; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
51; X86-NEXT:    addl {{[0-9]+}}(%esp), %ecx
52; X86-NEXT:    adcl {{[0-9]+}}(%esp), %esi
53; X86-NEXT:    seto %bl
54; X86-NEXT:    movl %esi, %eax
55; X86-NEXT:    sarl $31, %eax
56; X86-NEXT:    testb %bl, %bl
57; X86-NEXT:    cmovel %ecx, %eax
58; X86-NEXT:    xorl %edx, %edx
59; X86-NEXT:    testl %esi, %esi
60; X86-NEXT:    setns %dl
61; X86-NEXT:    addl $2147483647, %edx # imm = 0x7FFFFFFF
62; X86-NEXT:    testb %bl, %bl
63; X86-NEXT:    cmovel %esi, %edx
64; X86-NEXT:    popl %esi
65; X86-NEXT:    popl %ebx
66; X86-NEXT:    retl
67;
68; X64-LABEL: func64:
69; X64:       # %bb.0:
70; X64-NEXT:    xorl %ecx, %ecx
71; X64-NEXT:    movq %rdi, %rax
72; X64-NEXT:    addq %rdx, %rax
73; X64-NEXT:    setns %cl
74; X64-NEXT:    movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
75; X64-NEXT:    addq %rcx, %rax
76; X64-NEXT:    addq %rdx, %rdi
77; X64-NEXT:    cmovnoq %rdi, %rax
78; X64-NEXT:    retq
79  %a = mul i64 %y, %z
80  %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %z)
81  ret i64 %tmp
82}
83
84define signext i16 @func16(i16 signext %x, i16 signext %y, i16 signext %z) nounwind {
85; X86-LABEL: func16:
86; X86:       # %bb.0:
87; X86-NEXT:    pushl %esi
88; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
89; X86-NEXT:    imulw {{[0-9]+}}(%esp), %ax
90; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %edx
91; X86-NEXT:    xorl %ecx, %ecx
92; X86-NEXT:    movl %eax, %esi
93; X86-NEXT:    addw %dx, %si
94; X86-NEXT:    setns %cl
95; X86-NEXT:    addl $32767, %ecx # imm = 0x7FFF
96; X86-NEXT:    addw %dx, %ax
97; X86-NEXT:    cmovol %ecx, %eax
98; X86-NEXT:    # kill: def $ax killed $ax killed $eax
99; X86-NEXT:    popl %esi
100; X86-NEXT:    retl
101;
102; X64-LABEL: func16:
103; X64:       # %bb.0:
104; X64-NEXT:    imull %edx, %esi
105; X64-NEXT:    xorl %eax, %eax
106; X64-NEXT:    movl %edi, %ecx
107; X64-NEXT:    addw %si, %cx
108; X64-NEXT:    setns %al
109; X64-NEXT:    addl $32767, %eax # imm = 0x7FFF
110; X64-NEXT:    addw %si, %di
111; X64-NEXT:    cmovnol %edi, %eax
112; X64-NEXT:    # kill: def $ax killed $ax killed $eax
113; X64-NEXT:    retq
114  %a = mul i16 %y, %z
115  %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %a)
116  ret i16 %tmp
117}
118
119define signext i8 @func8(i8 signext %x, i8 signext %y, i8 signext %z) nounwind {
120; X86-LABEL: func8:
121; X86:       # %bb.0:
122; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
123; X86-NEXT:    mulb {{[0-9]+}}(%esp)
124; X86-NEXT:    movb {{[0-9]+}}(%esp), %dl
125; X86-NEXT:    xorl %ecx, %ecx
126; X86-NEXT:    movb %al, %ah
127; X86-NEXT:    addb %dl, %ah
128; X86-NEXT:    setns %cl
129; X86-NEXT:    addl $127, %ecx
130; X86-NEXT:    addb %dl, %al
131; X86-NEXT:    movzbl %al, %eax
132; X86-NEXT:    cmovol %ecx, %eax
133; X86-NEXT:    # kill: def $al killed $al killed $eax
134; X86-NEXT:    retl
135;
136; X64-LABEL: func8:
137; X64:       # %bb.0:
138; X64-NEXT:    movl %esi, %eax
139; X64-NEXT:    # kill: def $al killed $al killed $eax
140; X64-NEXT:    mulb %dl
141; X64-NEXT:    xorl %ecx, %ecx
142; X64-NEXT:    movl %edi, %edx
143; X64-NEXT:    addb %al, %dl
144; X64-NEXT:    setns %cl
145; X64-NEXT:    addl $127, %ecx
146; X64-NEXT:    addb %al, %dil
147; X64-NEXT:    movzbl %dil, %eax
148; X64-NEXT:    cmovol %ecx, %eax
149; X64-NEXT:    # kill: def $al killed $al killed $eax
150; X64-NEXT:    retq
151  %a = mul i8 %y, %z
152  %tmp = call i8 @llvm.sadd.sat.i8(i8 %x, i8 %a)
153  ret i8 %tmp
154}
155
156define signext i4 @func4(i4 signext %x, i4 signext %y, i4 signext %z) nounwind {
157; X86-LABEL: func4:
158; X86:       # %bb.0:
159; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
160; X86-NEXT:    mulb {{[0-9]+}}(%esp)
161; X86-NEXT:    shlb $4, %al
162; X86-NEXT:    sarb $4, %al
163; X86-NEXT:    addb {{[0-9]+}}(%esp), %al
164; X86-NEXT:    movzbl %al, %ecx
165; X86-NEXT:    cmpb $7, %al
166; X86-NEXT:    movl $7, %eax
167; X86-NEXT:    cmovll %ecx, %eax
168; X86-NEXT:    cmpb $-8, %al
169; X86-NEXT:    movl $248, %ecx
170; X86-NEXT:    cmovgl %eax, %ecx
171; X86-NEXT:    movsbl %cl, %eax
172; X86-NEXT:    retl
173;
174; X64-LABEL: func4:
175; X64:       # %bb.0:
176; X64-NEXT:    movl %esi, %eax
177; X64-NEXT:    # kill: def $al killed $al killed $eax
178; X64-NEXT:    mulb %dl
179; X64-NEXT:    shlb $4, %al
180; X64-NEXT:    sarb $4, %al
181; X64-NEXT:    addb %dil, %al
182; X64-NEXT:    movzbl %al, %eax
183; X64-NEXT:    cmpb $7, %al
184; X64-NEXT:    movl $7, %ecx
185; X64-NEXT:    cmovll %eax, %ecx
186; X64-NEXT:    cmpb $-8, %cl
187; X64-NEXT:    movl $248, %eax
188; X64-NEXT:    cmovgl %ecx, %eax
189; X64-NEXT:    movsbl %al, %eax
190; X64-NEXT:    retq
191  %a = mul i4 %y, %z
192  %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %a)
193  ret i4 %tmp
194}
195