Skip to content

Commit d8c8c67

Browse files
[X86][GlobalIsel] Add G_[U|S]MIN/G_[U|S]MAX scalar test coverage (#157621)
Adds isel test for supporting G_[U|S]MIN/G_[U|S]MAX.
1 parent 4de9bee commit d8c8c67

File tree

4 files changed

+756
-0
lines changed

4 files changed

+756
-0
lines changed

llvm/test/CodeGen/X86/isel-smax.ll

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64
3+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel | FileCheck %s --check-prefixes=FASTISEL-X64
4+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64
5+
; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86
6+
; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=FASTISEL-X86
7+
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86
8+
9+
define i8 @smax_i8(i8 %a, i8 %b) nounwind readnone {
10+
; X64-LABEL: smax_i8:
11+
; X64: # %bb.0:
12+
; X64-NEXT: movl %esi, %eax
13+
; X64-NEXT: cmpb %al, %dil
14+
; X64-NEXT: cmovgl %edi, %eax
15+
; X64-NEXT: # kill: def $al killed $al killed $eax
16+
; X64-NEXT: retq
17+
;
18+
; FASTISEL-X64-LABEL: smax_i8:
19+
; FASTISEL-X64: # %bb.0:
20+
; FASTISEL-X64-NEXT: movzbl %dil, %ecx
21+
; FASTISEL-X64-NEXT: movzbl %sil, %eax
22+
; FASTISEL-X64-NEXT: cmpb %al, %cl
23+
; FASTISEL-X64-NEXT: cmovgl %ecx, %eax
24+
; FASTISEL-X64-NEXT: # kill: def $al killed $al killed $eax
25+
; FASTISEL-X64-NEXT: retq
26+
;
27+
; X86-LABEL: smax_i8:
28+
; X86: # %bb.0:
29+
; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
30+
; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
31+
; X86-NEXT: cmpb %cl, %al
32+
; X86-NEXT: jg .LBB0_2
33+
; X86-NEXT: # %bb.1:
34+
; X86-NEXT: movl %ecx, %eax
35+
; X86-NEXT: .LBB0_2:
36+
; X86-NEXT: retl
37+
;
38+
; FASTISEL-X86-LABEL: smax_i8:
39+
; FASTISEL-X86: # %bb.0:
40+
; FASTISEL-X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
41+
; FASTISEL-X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
42+
; FASTISEL-X86-NEXT: cmpb %cl, %al
43+
; FASTISEL-X86-NEXT: jg .LBB0_2
44+
; FASTISEL-X86-NEXT: # %bb.1:
45+
; FASTISEL-X86-NEXT: movl %ecx, %eax
46+
; FASTISEL-X86-NEXT: .LBB0_2:
47+
; FASTISEL-X86-NEXT: retl
48+
%ret = call i8 @llvm.smax.i8(i8 %a, i8 %b)
49+
ret i8 %ret
50+
}
51+
define i16 @smax_i16(i16 %a, i16 %b) nounwind readnone {
52+
; X64-LABEL: smax_i16:
53+
; X64: # %bb.0:
54+
; X64-NEXT: movl %esi, %eax
55+
; X64-NEXT: cmpw %ax, %di
56+
; X64-NEXT: cmovgl %edi, %eax
57+
; X64-NEXT: # kill: def $ax killed $ax killed $eax
58+
; X64-NEXT: retq
59+
;
60+
; FASTISEL-X64-LABEL: smax_i16:
61+
; FASTISEL-X64: # %bb.0:
62+
; FASTISEL-X64-NEXT: movl %esi, %eax
63+
; FASTISEL-X64-NEXT: cmpw %ax, %di
64+
; FASTISEL-X64-NEXT: cmovgl %edi, %eax
65+
; FASTISEL-X64-NEXT: # kill: def $ax killed $ax killed $eax
66+
; FASTISEL-X64-NEXT: retq
67+
;
68+
; X86-LABEL: smax_i16:
69+
; X86: # %bb.0:
70+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
71+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
72+
; X86-NEXT: cmpw %cx, %ax
73+
; X86-NEXT: jg .LBB1_2
74+
; X86-NEXT: # %bb.1:
75+
; X86-NEXT: movl %ecx, %eax
76+
; X86-NEXT: .LBB1_2:
77+
; X86-NEXT: # kill: def $ax killed $ax killed $eax
78+
; X86-NEXT: retl
79+
;
80+
; FASTISEL-X86-LABEL: smax_i16:
81+
; FASTISEL-X86: # %bb.0:
82+
; FASTISEL-X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
83+
; FASTISEL-X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
84+
; FASTISEL-X86-NEXT: cmpw %cx, %ax
85+
; FASTISEL-X86-NEXT: jg .LBB1_2
86+
; FASTISEL-X86-NEXT: # %bb.1:
87+
; FASTISEL-X86-NEXT: movl %ecx, %eax
88+
; FASTISEL-X86-NEXT: .LBB1_2:
89+
; FASTISEL-X86-NEXT: # kill: def $ax killed $ax killed $eax
90+
; FASTISEL-X86-NEXT: retl
91+
%ret = call i16 @llvm.smax.i16(i16 %a, i16 %b)
92+
ret i16 %ret
93+
}
94+
define i32 @smax_i32(i32 %a, i32 %b) nounwind readnone {
95+
; X64-LABEL: smax_i32:
96+
; X64: # %bb.0:
97+
; X64-NEXT: movl %esi, %eax
98+
; X64-NEXT: cmpl %esi, %edi
99+
; X64-NEXT: cmovgl %edi, %eax
100+
; X64-NEXT: retq
101+
;
102+
; FASTISEL-X64-LABEL: smax_i32:
103+
; FASTISEL-X64: # %bb.0:
104+
; FASTISEL-X64-NEXT: movl %esi, %eax
105+
; FASTISEL-X64-NEXT: cmpl %esi, %edi
106+
; FASTISEL-X64-NEXT: cmovgl %edi, %eax
107+
; FASTISEL-X64-NEXT: retq
108+
;
109+
; X86-LABEL: smax_i32:
110+
; X86: # %bb.0:
111+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
112+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
113+
; X86-NEXT: cmpl %ecx, %eax
114+
; X86-NEXT: jg .LBB2_2
115+
; X86-NEXT: # %bb.1:
116+
; X86-NEXT: movl %ecx, %eax
117+
; X86-NEXT: .LBB2_2:
118+
; X86-NEXT: retl
119+
;
120+
; FASTISEL-X86-LABEL: smax_i32:
121+
; FASTISEL-X86: # %bb.0:
122+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
123+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
124+
; FASTISEL-X86-NEXT: cmpl %ecx, %eax
125+
; FASTISEL-X86-NEXT: jg .LBB2_2
126+
; FASTISEL-X86-NEXT: # %bb.1:
127+
; FASTISEL-X86-NEXT: movl %ecx, %eax
128+
; FASTISEL-X86-NEXT: .LBB2_2:
129+
; FASTISEL-X86-NEXT: retl
130+
%ret = call i32 @llvm.smax.i32(i32 %a, i32 %b)
131+
ret i32 %ret
132+
}
133+
define i64 @smax_i64(i64 %a, i64 %b) nounwind readnone {
134+
; X64-LABEL: smax_i64:
135+
; X64: # %bb.0:
136+
; X64-NEXT: movq %rsi, %rax
137+
; X64-NEXT: cmpq %rsi, %rdi
138+
; X64-NEXT: cmovgq %rdi, %rax
139+
; X64-NEXT: retq
140+
;
141+
; FASTISEL-X64-LABEL: smax_i64:
142+
; FASTISEL-X64: # %bb.0:
143+
; FASTISEL-X64-NEXT: movq %rsi, %rax
144+
; FASTISEL-X64-NEXT: cmpq %rsi, %rdi
145+
; FASTISEL-X64-NEXT: cmovgq %rdi, %rax
146+
; FASTISEL-X64-NEXT: retq
147+
;
148+
; X86-LABEL: smax_i64:
149+
; X86: # %bb.0:
150+
; X86-NEXT: pushl %edi
151+
; X86-NEXT: pushl %esi
152+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
153+
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
154+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
155+
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
156+
; X86-NEXT: cmpl %eax, %ecx
157+
; X86-NEXT: movl %esi, %edi
158+
; X86-NEXT: sbbl %edx, %edi
159+
; X86-NEXT: jl .LBB3_2
160+
; X86-NEXT: # %bb.1:
161+
; X86-NEXT: movl %ecx, %eax
162+
; X86-NEXT: movl %esi, %edx
163+
; X86-NEXT: .LBB3_2:
164+
; X86-NEXT: popl %esi
165+
; X86-NEXT: popl %edi
166+
; X86-NEXT: retl
167+
;
168+
; FASTISEL-X86-LABEL: smax_i64:
169+
; FASTISEL-X86: # %bb.0:
170+
; FASTISEL-X86-NEXT: pushl %edi
171+
; FASTISEL-X86-NEXT: pushl %esi
172+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
173+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %esi
174+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %edx
175+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
176+
; FASTISEL-X86-NEXT: cmpl %eax, %esi
177+
; FASTISEL-X86-NEXT: movl %ecx, %edi
178+
; FASTISEL-X86-NEXT: sbbl %edx, %edi
179+
; FASTISEL-X86-NEXT: jl .LBB3_2
180+
; FASTISEL-X86-NEXT: # %bb.1:
181+
; FASTISEL-X86-NEXT: movl %esi, %eax
182+
; FASTISEL-X86-NEXT: movl %ecx, %edx
183+
; FASTISEL-X86-NEXT: .LBB3_2:
184+
; FASTISEL-X86-NEXT: popl %esi
185+
; FASTISEL-X86-NEXT: popl %edi
186+
; FASTISEL-X86-NEXT: retl
187+
%ret = call i64 @llvm.smax.i64(i64 %a, i64 %b)
188+
ret i64 %ret
189+
}

llvm/test/CodeGen/X86/isel-smin.ll

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64
3+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel | FileCheck %s --check-prefixes=FASTISEL-X64
4+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X64
5+
; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86
6+
; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=FASTISEL-X86
7+
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86
8+
9+
define i8 @smin_i8(i8 %a, i8 %b) nounwind readnone {
10+
; X64-LABEL: smin_i8:
11+
; X64: # %bb.0:
12+
; X64-NEXT: movl %esi, %eax
13+
; X64-NEXT: cmpb %al, %dil
14+
; X64-NEXT: cmovll %edi, %eax
15+
; X64-NEXT: # kill: def $al killed $al killed $eax
16+
; X64-NEXT: retq
17+
;
18+
; FASTISEL-X64-LABEL: smin_i8:
19+
; FASTISEL-X64: # %bb.0:
20+
; FASTISEL-X64-NEXT: movzbl %dil, %ecx
21+
; FASTISEL-X64-NEXT: movzbl %sil, %eax
22+
; FASTISEL-X64-NEXT: cmpb %al, %cl
23+
; FASTISEL-X64-NEXT: cmovll %ecx, %eax
24+
; FASTISEL-X64-NEXT: # kill: def $al killed $al killed $eax
25+
; FASTISEL-X64-NEXT: retq
26+
;
27+
; X86-LABEL: smin_i8:
28+
; X86: # %bb.0:
29+
; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
30+
; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
31+
; X86-NEXT: cmpb %cl, %al
32+
; X86-NEXT: jl .LBB0_2
33+
; X86-NEXT: # %bb.1:
34+
; X86-NEXT: movl %ecx, %eax
35+
; X86-NEXT: .LBB0_2:
36+
; X86-NEXT: retl
37+
;
38+
; FASTISEL-X86-LABEL: smin_i8:
39+
; FASTISEL-X86: # %bb.0:
40+
; FASTISEL-X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
41+
; FASTISEL-X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
42+
; FASTISEL-X86-NEXT: cmpb %cl, %al
43+
; FASTISEL-X86-NEXT: jl .LBB0_2
44+
; FASTISEL-X86-NEXT: # %bb.1:
45+
; FASTISEL-X86-NEXT: movl %ecx, %eax
46+
; FASTISEL-X86-NEXT: .LBB0_2:
47+
; FASTISEL-X86-NEXT: retl
48+
%ret = call i8 @llvm.smin.i8(i8 %a, i8 %b)
49+
ret i8 %ret
50+
}
51+
define i16 @smin_i16(i16 %a, i16 %b) nounwind readnone {
52+
; X64-LABEL: smin_i16:
53+
; X64: # %bb.0:
54+
; X64-NEXT: movl %esi, %eax
55+
; X64-NEXT: cmpw %ax, %di
56+
; X64-NEXT: cmovll %edi, %eax
57+
; X64-NEXT: # kill: def $ax killed $ax killed $eax
58+
; X64-NEXT: retq
59+
;
60+
; FASTISEL-X64-LABEL: smin_i16:
61+
; FASTISEL-X64: # %bb.0:
62+
; FASTISEL-X64-NEXT: movl %esi, %eax
63+
; FASTISEL-X64-NEXT: cmpw %ax, %di
64+
; FASTISEL-X64-NEXT: cmovll %edi, %eax
65+
; FASTISEL-X64-NEXT: # kill: def $ax killed $ax killed $eax
66+
; FASTISEL-X64-NEXT: retq
67+
;
68+
; X86-LABEL: smin_i16:
69+
; X86: # %bb.0:
70+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
71+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
72+
; X86-NEXT: cmpw %cx, %ax
73+
; X86-NEXT: jl .LBB1_2
74+
; X86-NEXT: # %bb.1:
75+
; X86-NEXT: movl %ecx, %eax
76+
; X86-NEXT: .LBB1_2:
77+
; X86-NEXT: # kill: def $ax killed $ax killed $eax
78+
; X86-NEXT: retl
79+
;
80+
; FASTISEL-X86-LABEL: smin_i16:
81+
; FASTISEL-X86: # %bb.0:
82+
; FASTISEL-X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
83+
; FASTISEL-X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
84+
; FASTISEL-X86-NEXT: cmpw %cx, %ax
85+
; FASTISEL-X86-NEXT: jl .LBB1_2
86+
; FASTISEL-X86-NEXT: # %bb.1:
87+
; FASTISEL-X86-NEXT: movl %ecx, %eax
88+
; FASTISEL-X86-NEXT: .LBB1_2:
89+
; FASTISEL-X86-NEXT: # kill: def $ax killed $ax killed $eax
90+
; FASTISEL-X86-NEXT: retl
91+
%ret = call i16 @llvm.smin.i16(i16 %a, i16 %b)
92+
ret i16 %ret
93+
}
94+
define i32 @smin_i32(i32 %a, i32 %b) nounwind readnone {
95+
; X64-LABEL: smin_i32:
96+
; X64: # %bb.0:
97+
; X64-NEXT: movl %esi, %eax
98+
; X64-NEXT: cmpl %esi, %edi
99+
; X64-NEXT: cmovll %edi, %eax
100+
; X64-NEXT: retq
101+
;
102+
; FASTISEL-X64-LABEL: smin_i32:
103+
; FASTISEL-X64: # %bb.0:
104+
; FASTISEL-X64-NEXT: movl %esi, %eax
105+
; FASTISEL-X64-NEXT: cmpl %esi, %edi
106+
; FASTISEL-X64-NEXT: cmovll %edi, %eax
107+
; FASTISEL-X64-NEXT: retq
108+
;
109+
; X86-LABEL: smin_i32:
110+
; X86: # %bb.0:
111+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
112+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
113+
; X86-NEXT: cmpl %ecx, %eax
114+
; X86-NEXT: jl .LBB2_2
115+
; X86-NEXT: # %bb.1:
116+
; X86-NEXT: movl %ecx, %eax
117+
; X86-NEXT: .LBB2_2:
118+
; X86-NEXT: retl
119+
;
120+
; FASTISEL-X86-LABEL: smin_i32:
121+
; FASTISEL-X86: # %bb.0:
122+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
123+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
124+
; FASTISEL-X86-NEXT: cmpl %ecx, %eax
125+
; FASTISEL-X86-NEXT: jl .LBB2_2
126+
; FASTISEL-X86-NEXT: # %bb.1:
127+
; FASTISEL-X86-NEXT: movl %ecx, %eax
128+
; FASTISEL-X86-NEXT: .LBB2_2:
129+
; FASTISEL-X86-NEXT: retl
130+
%ret = call i32 @llvm.smin.i32(i32 %a, i32 %b)
131+
ret i32 %ret
132+
}
133+
define i64 @smin_i64(i64 %a, i64 %b) nounwind readnone {
134+
; X64-LABEL: smin_i64:
135+
; X64: # %bb.0:
136+
; X64-NEXT: movq %rsi, %rax
137+
; X64-NEXT: cmpq %rsi, %rdi
138+
; X64-NEXT: cmovlq %rdi, %rax
139+
; X64-NEXT: retq
140+
;
141+
; FASTISEL-X64-LABEL: smin_i64:
142+
; FASTISEL-X64: # %bb.0:
143+
; FASTISEL-X64-NEXT: movq %rsi, %rax
144+
; FASTISEL-X64-NEXT: cmpq %rsi, %rdi
145+
; FASTISEL-X64-NEXT: cmovlq %rdi, %rax
146+
; FASTISEL-X64-NEXT: retq
147+
;
148+
; X86-LABEL: smin_i64:
149+
; X86: # %bb.0:
150+
; X86-NEXT: pushl %edi
151+
; X86-NEXT: pushl %esi
152+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
153+
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
154+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
155+
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
156+
; X86-NEXT: cmpl %ecx, %eax
157+
; X86-NEXT: movl %edx, %edi
158+
; X86-NEXT: sbbl %esi, %edi
159+
; X86-NEXT: jl .LBB3_2
160+
; X86-NEXT: # %bb.1:
161+
; X86-NEXT: movl %ecx, %eax
162+
; X86-NEXT: movl %esi, %edx
163+
; X86-NEXT: .LBB3_2:
164+
; X86-NEXT: popl %esi
165+
; X86-NEXT: popl %edi
166+
; X86-NEXT: retl
167+
;
168+
; FASTISEL-X86-LABEL: smin_i64:
169+
; FASTISEL-X86: # %bb.0:
170+
; FASTISEL-X86-NEXT: pushl %edi
171+
; FASTISEL-X86-NEXT: pushl %esi
172+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
173+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %esi
174+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %edx
175+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
176+
; FASTISEL-X86-NEXT: cmpl %esi, %eax
177+
; FASTISEL-X86-NEXT: movl %edx, %edi
178+
; FASTISEL-X86-NEXT: sbbl %ecx, %edi
179+
; FASTISEL-X86-NEXT: jl .LBB3_2
180+
; FASTISEL-X86-NEXT: # %bb.1:
181+
; FASTISEL-X86-NEXT: movl %esi, %eax
182+
; FASTISEL-X86-NEXT: movl %ecx, %edx
183+
; FASTISEL-X86-NEXT: .LBB3_2:
184+
; FASTISEL-X86-NEXT: popl %esi
185+
; FASTISEL-X86-NEXT: popl %edi
186+
; FASTISEL-X86-NEXT: retl
187+
%ret = call i64 @llvm.smin.i64(i64 %a, i64 %b)
188+
ret i64 %ret
189+
}

0 commit comments

Comments
 (0)