Skip to content

Commit 40dc535

Browse files
committed
[x86] add tests for maxnum/minnum with nnan; NFC
1 parent 630d37d commit 40dc535

File tree

2 files changed

+164
-0
lines changed

2 files changed

+164
-0
lines changed

llvm/test/Analysis/CostModel/X86/fmaxnum.ll

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,88 @@ define i32 @f64(i32 %arg) {
9292
ret i32 undef
9393
}
9494

95+
define i32 @f32_nnan(i32 %arg) {
96+
; SSE-LABEL: 'f32_nnan'
97+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %F32 = call nnan float @llvm.maxnum.f32(float undef, float undef)
98+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F32 = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> undef, <2 x float> undef)
99+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4F32 = call nnan <4 x float> @llvm.maxnum.v4f32(<4 x float> undef, <4 x float> undef)
100+
; SSE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V8F32 = call nnan <8 x float> @llvm.maxnum.v8f32(<8 x float> undef, <8 x float> undef)
101+
; SSE-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V16F32 = call nnan <16 x float> @llvm.maxnum.v16f32(<16 x float> undef, <16 x float> undef)
102+
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
103+
;
104+
; AVX1-LABEL: 'f32_nnan'
105+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %F32 = call nnan float @llvm.maxnum.f32(float undef, float undef)
106+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2F32 = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> undef, <2 x float> undef)
107+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4F32 = call nnan <4 x float> @llvm.maxnum.v4f32(<4 x float> undef, <4 x float> undef)
108+
; AVX1-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %V8F32 = call nnan <8 x float> @llvm.maxnum.v8f32(<8 x float> undef, <8 x float> undef)
109+
; AVX1-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %V16F32 = call nnan <16 x float> @llvm.maxnum.v16f32(<16 x float> undef, <16 x float> undef)
110+
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
111+
;
112+
; AVX2-LABEL: 'f32_nnan'
113+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %F32 = call nnan float @llvm.maxnum.f32(float undef, float undef)
114+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2F32 = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> undef, <2 x float> undef)
115+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4F32 = call nnan <4 x float> @llvm.maxnum.v4f32(<4 x float> undef, <4 x float> undef)
116+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V8F32 = call nnan <8 x float> @llvm.maxnum.v8f32(<8 x float> undef, <8 x float> undef)
117+
; AVX2-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V16F32 = call nnan <16 x float> @llvm.maxnum.v16f32(<16 x float> undef, <16 x float> undef)
118+
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
119+
;
120+
; AVX512-LABEL: 'f32_nnan'
121+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %F32 = call nnan float @llvm.maxnum.f32(float undef, float undef)
122+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2F32 = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> undef, <2 x float> undef)
123+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4F32 = call nnan <4 x float> @llvm.maxnum.v4f32(<4 x float> undef, <4 x float> undef)
124+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8F32 = call nnan <8 x float> @llvm.maxnum.v8f32(<8 x float> undef, <8 x float> undef)
125+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V16F32 = call nnan <16 x float> @llvm.maxnum.v16f32(<16 x float> undef, <16 x float> undef)
126+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
127+
;
128+
%F32 = call nnan float @llvm.maxnum.f32(float undef, float undef)
129+
%V2F32 = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> undef, <2 x float> undef)
130+
%V4F32 = call nnan <4 x float> @llvm.maxnum.v4f32(<4 x float> undef, <4 x float> undef)
131+
%V8F32 = call nnan <8 x float> @llvm.maxnum.v8f32(<8 x float> undef, <8 x float> undef)
132+
%V16F32 = call nnan <16 x float> @llvm.maxnum.v16f32(<16 x float> undef, <16 x float> undef)
133+
ret i32 undef
134+
}
135+
136+
define i32 @f64_nnan(i32 %arg) {
137+
; SSE-LABEL: 'f64_nnan'
138+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %f64 = call nnan double @llvm.maxnum.f64(double undef, double undef)
139+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2f64 = call nnan <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> undef)
140+
; SSE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4f64 = call nnan <4 x double> @llvm.maxnum.v4f64(<4 x double> undef, <4 x double> undef)
141+
; SSE-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V8f64 = call nnan <8 x double> @llvm.maxnum.v8f64(<8 x double> undef, <8 x double> undef)
142+
; SSE-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V16f64 = call nnan <16 x double> @llvm.maxnum.v16f64(<16 x double> undef, <16 x double> undef)
143+
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
144+
;
145+
; AVX1-LABEL: 'f64_nnan'
146+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %f64 = call nnan double @llvm.maxnum.f64(double undef, double undef)
147+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2f64 = call nnan <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> undef)
148+
; AVX1-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %V4f64 = call nnan <4 x double> @llvm.maxnum.v4f64(<4 x double> undef, <4 x double> undef)
149+
; AVX1-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %V8f64 = call nnan <8 x double> @llvm.maxnum.v8f64(<8 x double> undef, <8 x double> undef)
150+
; AVX1-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %V16f64 = call nnan <16 x double> @llvm.maxnum.v16f64(<16 x double> undef, <16 x double> undef)
151+
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
152+
;
153+
; AVX2-LABEL: 'f64_nnan'
154+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %f64 = call nnan double @llvm.maxnum.f64(double undef, double undef)
155+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2f64 = call nnan <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> undef)
156+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4f64 = call nnan <4 x double> @llvm.maxnum.v4f64(<4 x double> undef, <4 x double> undef)
157+
; AVX2-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V8f64 = call nnan <8 x double> @llvm.maxnum.v8f64(<8 x double> undef, <8 x double> undef)
158+
; AVX2-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V16f64 = call nnan <16 x double> @llvm.maxnum.v16f64(<16 x double> undef, <16 x double> undef)
159+
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
160+
;
161+
; AVX512-LABEL: 'f64_nnan'
162+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %f64 = call nnan double @llvm.maxnum.f64(double undef, double undef)
163+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2f64 = call nnan <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> undef)
164+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4f64 = call nnan <4 x double> @llvm.maxnum.v4f64(<4 x double> undef, <4 x double> undef)
165+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8f64 = call nnan <8 x double> @llvm.maxnum.v8f64(<8 x double> undef, <8 x double> undef)
166+
; AVX512-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V16f64 = call nnan <16 x double> @llvm.maxnum.v16f64(<16 x double> undef, <16 x double> undef)
167+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
168+
;
169+
%f64 = call nnan double @llvm.maxnum.f64(double undef, double undef)
170+
%V2f64 = call nnan <2 x double> @llvm.maxnum.v2f64(<2 x double> undef, <2 x double> undef)
171+
%V4f64 = call nnan <4 x double> @llvm.maxnum.v4f64(<4 x double> undef, <4 x double> undef)
172+
%V8f64 = call nnan <8 x double> @llvm.maxnum.v8f64(<8 x double> undef, <8 x double> undef)
173+
%V16f64 = call nnan <16 x double> @llvm.maxnum.v16f64(<16 x double> undef, <16 x double> undef)
174+
ret i32 undef
175+
}
176+
95177
declare float @llvm.maxnum.f32(float, float)
96178
declare <2 x float> @llvm.maxnum.v2f32(<2 x float>, <2 x float>)
97179
declare <4 x float> @llvm.maxnum.v4f32(<4 x float>, <4 x float>)

llvm/test/Analysis/CostModel/X86/fminnum.ll

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,88 @@ define i32 @f64(i32 %arg) {
9292
ret i32 undef
9393
}
9494

95+
define i32 @f32_nnan(i32 %arg) {
96+
; SSE-LABEL: 'f32_nnan'
97+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %F32 = call nnan float @llvm.minnum.f32(float undef, float undef)
98+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2F32 = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> undef, <2 x float> undef)
99+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4F32 = call nnan <4 x float> @llvm.minnum.v4f32(<4 x float> undef, <4 x float> undef)
100+
; SSE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V8F32 = call nnan <8 x float> @llvm.minnum.v8f32(<8 x float> undef, <8 x float> undef)
101+
; SSE-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V16F32 = call nnan <16 x float> @llvm.minnum.v16f32(<16 x float> undef, <16 x float> undef)
102+
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
103+
;
104+
; AVX1-LABEL: 'f32_nnan'
105+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %F32 = call nnan float @llvm.minnum.f32(float undef, float undef)
106+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2F32 = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> undef, <2 x float> undef)
107+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4F32 = call nnan <4 x float> @llvm.minnum.v4f32(<4 x float> undef, <4 x float> undef)
108+
; AVX1-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %V8F32 = call nnan <8 x float> @llvm.minnum.v8f32(<8 x float> undef, <8 x float> undef)
109+
; AVX1-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %V16F32 = call nnan <16 x float> @llvm.minnum.v16f32(<16 x float> undef, <16 x float> undef)
110+
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
111+
;
112+
; AVX2-LABEL: 'f32_nnan'
113+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %F32 = call nnan float @llvm.minnum.f32(float undef, float undef)
114+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2F32 = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> undef, <2 x float> undef)
115+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4F32 = call nnan <4 x float> @llvm.minnum.v4f32(<4 x float> undef, <4 x float> undef)
116+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V8F32 = call nnan <8 x float> @llvm.minnum.v8f32(<8 x float> undef, <8 x float> undef)
117+
; AVX2-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V16F32 = call nnan <16 x float> @llvm.minnum.v16f32(<16 x float> undef, <16 x float> undef)
118+
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
119+
;
120+
; AVX512-LABEL: 'f32_nnan'
121+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %F32 = call nnan float @llvm.minnum.f32(float undef, float undef)
122+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2F32 = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> undef, <2 x float> undef)
123+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4F32 = call nnan <4 x float> @llvm.minnum.v4f32(<4 x float> undef, <4 x float> undef)
124+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8F32 = call nnan <8 x float> @llvm.minnum.v8f32(<8 x float> undef, <8 x float> undef)
125+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V16F32 = call nnan <16 x float> @llvm.minnum.v16f32(<16 x float> undef, <16 x float> undef)
126+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
127+
;
128+
%F32 = call nnan float @llvm.minnum.f32(float undef, float undef)
129+
%V2F32 = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> undef, <2 x float> undef)
130+
%V4F32 = call nnan <4 x float> @llvm.minnum.v4f32(<4 x float> undef, <4 x float> undef)
131+
%V8F32 = call nnan <8 x float> @llvm.minnum.v8f32(<8 x float> undef, <8 x float> undef)
132+
%V16F32 = call nnan <16 x float> @llvm.minnum.v16f32(<16 x float> undef, <16 x float> undef)
133+
ret i32 undef
134+
}
135+
136+
define i32 @f64_nnan(i32 %arg) {
137+
; SSE-LABEL: 'f64_nnan'
138+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %f64 = call nnan double @llvm.minnum.f64(double undef, double undef)
139+
; SSE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2f64 = call nnan <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> undef)
140+
; SSE-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4f64 = call nnan <4 x double> @llvm.minnum.v4f64(<4 x double> undef, <4 x double> undef)
141+
; SSE-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V8f64 = call nnan <8 x double> @llvm.minnum.v8f64(<8 x double> undef, <8 x double> undef)
142+
; SSE-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V16f64 = call nnan <16 x double> @llvm.minnum.v16f64(<16 x double> undef, <16 x double> undef)
143+
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
144+
;
145+
; AVX1-LABEL: 'f64_nnan'
146+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %f64 = call nnan double @llvm.minnum.f64(double undef, double undef)
147+
; AVX1-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2f64 = call nnan <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> undef)
148+
; AVX1-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %V4f64 = call nnan <4 x double> @llvm.minnum.v4f64(<4 x double> undef, <4 x double> undef)
149+
; AVX1-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %V8f64 = call nnan <8 x double> @llvm.minnum.v8f64(<8 x double> undef, <8 x double> undef)
150+
; AVX1-NEXT: Cost Model: Found an estimated cost of 20 for instruction: %V16f64 = call nnan <16 x double> @llvm.minnum.v16f64(<16 x double> undef, <16 x double> undef)
151+
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
152+
;
153+
; AVX2-LABEL: 'f64_nnan'
154+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %f64 = call nnan double @llvm.minnum.f64(double undef, double undef)
155+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2f64 = call nnan <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> undef)
156+
; AVX2-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4f64 = call nnan <4 x double> @llvm.minnum.v4f64(<4 x double> undef, <4 x double> undef)
157+
; AVX2-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V8f64 = call nnan <8 x double> @llvm.minnum.v8f64(<8 x double> undef, <8 x double> undef)
158+
; AVX2-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V16f64 = call nnan <16 x double> @llvm.minnum.v16f64(<16 x double> undef, <16 x double> undef)
159+
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
160+
;
161+
; AVX512-LABEL: 'f64_nnan'
162+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %f64 = call nnan double @llvm.minnum.f64(double undef, double undef)
163+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2f64 = call nnan <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> undef)
164+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V4f64 = call nnan <4 x double> @llvm.minnum.v4f64(<4 x double> undef, <4 x double> undef)
165+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8f64 = call nnan <8 x double> @llvm.minnum.v8f64(<8 x double> undef, <8 x double> undef)
166+
; AVX512-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V16f64 = call nnan <16 x double> @llvm.minnum.v16f64(<16 x double> undef, <16 x double> undef)
167+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
168+
;
169+
%f64 = call nnan double @llvm.minnum.f64(double undef, double undef)
170+
%V2f64 = call nnan <2 x double> @llvm.minnum.v2f64(<2 x double> undef, <2 x double> undef)
171+
%V4f64 = call nnan <4 x double> @llvm.minnum.v4f64(<4 x double> undef, <4 x double> undef)
172+
%V8f64 = call nnan <8 x double> @llvm.minnum.v8f64(<8 x double> undef, <8 x double> undef)
173+
%V16f64 = call nnan <16 x double> @llvm.minnum.v16f64(<16 x double> undef, <16 x double> undef)
174+
ret i32 undef
175+
}
176+
95177
declare float @llvm.minnum.f32(float, float)
96178
declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>)
97179
declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>)

0 commit comments

Comments
 (0)