Skip to content

Commit c0aa97b

Browse files
committed
[X86] Add cost model test cases for fmin/fmax reduction.
1 parent fc93787 commit c0aa97b

File tree

2 files changed

+220
-0
lines changed

2 files changed

+220
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,SSE,SSE2
3+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+ssse3 | FileCheck %s --check-prefixes=CHECK,SSE,SSSE3
4+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+sse4.2 | FileCheck %s --check-prefixes=CHECK,SSE,SSE42
5+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX,AVX1
6+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX,AVX2
7+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+avx512f | FileCheck %s --check-prefixes=CHECK,AVX512,AVX512F
8+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+avx512f,+avx512bw | FileCheck %s --check-prefixes=CHECK,AVX512,AVX512BW
9+
; RUN: opt < %s -cost-model -mtriple=x86_64-apple-darwin -analyze -mattr=+avx512f,+avx512dq | FileCheck %s --check-prefixes=CHECK,AVX512,AVX512DQ
10+
11+
define i32 @reduce_f64(i32 %arg) {
12+
; SSE-LABEL: 'reduce_f64'
13+
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call double @llvm.experimental.vector.reduce.fmax.v1f64(<1 x double> undef)
14+
; SSE-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2 = call double @llvm.experimental.vector.reduce.fmax.v2f64(<2 x double> undef)
15+
; SSE-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V4 = call double @llvm.experimental.vector.reduce.fmax.v4f64(<4 x double> undef)
16+
; SSE-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V8 = call double @llvm.experimental.vector.reduce.fmax.v8f64(<8 x double> undef)
17+
; SSE-NEXT: Cost Model: Found an estimated cost of 24 for instruction: %V16 = call double @llvm.experimental.vector.reduce.fmax.v16f64(<16 x double> undef)
18+
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
19+
;
20+
; AVX-LABEL: 'reduce_f64'
21+
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call double @llvm.experimental.vector.reduce.fmax.v1f64(<1 x double> undef)
22+
; AVX-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2 = call double @llvm.experimental.vector.reduce.fmax.v2f64(<2 x double> undef)
23+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4 = call double @llvm.experimental.vector.reduce.fmax.v4f64(<4 x double> undef)
24+
; AVX-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V8 = call double @llvm.experimental.vector.reduce.fmax.v8f64(<8 x double> undef)
25+
; AVX-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V16 = call double @llvm.experimental.vector.reduce.fmax.v16f64(<16 x double> undef)
26+
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
27+
;
28+
; AVX512-LABEL: 'reduce_f64'
29+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call double @llvm.experimental.vector.reduce.fmax.v1f64(<1 x double> undef)
30+
; AVX512-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2 = call double @llvm.experimental.vector.reduce.fmax.v2f64(<2 x double> undef)
31+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4 = call double @llvm.experimental.vector.reduce.fmax.v4f64(<4 x double> undef)
32+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V8 = call double @llvm.experimental.vector.reduce.fmax.v8f64(<8 x double> undef)
33+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V16 = call double @llvm.experimental.vector.reduce.fmax.v16f64(<16 x double> undef)
34+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
35+
;
36+
%V1 = call double @llvm.experimental.vector.reduce.fmax.v1f64(<1 x double> undef)
37+
%V2 = call double @llvm.experimental.vector.reduce.fmax.v2f64(<2 x double> undef)
38+
%V4 = call double @llvm.experimental.vector.reduce.fmax.v4f64(<4 x double> undef)
39+
%V8 = call double @llvm.experimental.vector.reduce.fmax.v8f64(<8 x double> undef)
40+
%V16 = call double @llvm.experimental.vector.reduce.fmax.v16f64(<16 x double> undef)
41+
ret i32 undef
42+
}
43+
44+
define i32 @reduce_f32(i32 %arg) {
45+
; SSE2-LABEL: 'reduce_f32'
46+
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float> undef)
47+
; SSE2-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2 = call float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float> undef)
48+
; SSE2-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4 = call float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float> undef)
49+
; SSE2-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V8 = call float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float> undef)
50+
; SSE2-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V16 = call float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float> undef)
51+
; SSE2-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V32 = call float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float> undef)
52+
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
53+
;
54+
; SSSE3-LABEL: 'reduce_f32'
55+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float> undef)
56+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2 = call float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float> undef)
57+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4 = call float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float> undef)
58+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V8 = call float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float> undef)
59+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V16 = call float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float> undef)
60+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 32 for instruction: %V32 = call float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float> undef)
61+
; SSSE3-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
62+
;
63+
; SSE42-LABEL: 'reduce_f32'
64+
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float> undef)
65+
; SSE42-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2 = call float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float> undef)
66+
; SSE42-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V4 = call float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float> undef)
67+
; SSE42-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V8 = call float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float> undef)
68+
; SSE42-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V16 = call float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float> undef)
69+
; SSE42-NEXT: Cost Model: Found an estimated cost of 24 for instruction: %V32 = call float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float> undef)
70+
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
71+
;
72+
; AVX-LABEL: 'reduce_f32'
73+
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float> undef)
74+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V2 = call float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float> undef)
75+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4 = call float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float> undef)
76+
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V8 = call float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float> undef)
77+
; AVX-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V16 = call float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float> undef)
78+
; AVX-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V32 = call float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float> undef)
79+
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
80+
;
81+
; AVX512-LABEL: 'reduce_f32'
82+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %V1 = call float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float> undef)
83+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V2 = call float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float> undef)
84+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V4 = call float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float> undef)
85+
; AVX512-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %V8 = call float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float> undef)
86+
; AVX512-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V16 = call float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float> undef)
87+
; AVX512-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V32 = call float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float> undef)
88+
; AVX512-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
89+
;
90+
%V1 = call float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float> undef)
91+
%V2 = call float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float> undef)
92+
%V4 = call float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float> undef)
93+
%V8 = call float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float> undef)
94+
%V16 = call float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float> undef)
95+
%V32 = call float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float> undef)
96+
ret i32 undef
97+
}
98+
99+
declare double @llvm.experimental.vector.reduce.fmax.v1f64(<1 x double>)
100+
declare double @llvm.experimental.vector.reduce.fmax.v2f64(<2 x double>)
101+
declare double @llvm.experimental.vector.reduce.fmax.v4f64(<4 x double>)
102+
declare double @llvm.experimental.vector.reduce.fmax.v8f64(<8 x double>)
103+
declare double @llvm.experimental.vector.reduce.fmax.v16f64(<16 x double>)
104+
105+
declare float @llvm.experimental.vector.reduce.fmax.v1f32(<1 x float>)
106+
declare float @llvm.experimental.vector.reduce.fmax.v2f32(<2 x float>)
107+
declare float @llvm.experimental.vector.reduce.fmax.v4f32(<4 x float>)
108+
declare float @llvm.experimental.vector.reduce.fmax.v8f32(<8 x float>)
109+
declare float @llvm.experimental.vector.reduce.fmax.v16f32(<16 x float>)
110+
declare float @llvm.experimental.vector.reduce.fmax.v32f32(<32 x float>)

0 commit comments

Comments
 (0)