xref: /llvm-project/llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll (revision 580210a0c938531ef9fd79f9ffedb93eeb2e66c2)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -mtriple=x86_64-unknown -passes=slp-vectorizer -S | FileCheck %s --check-prefixes=CHECK,SSE
3; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=corei7-avx -passes=slp-vectorizer -S | FileCheck %s --check-prefixes=CHECK,AVX,AVX256
4; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=bdver1 -passes=slp-vectorizer -S | FileCheck %s --check-prefixes=CHECK,AVX,AVX256
5; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=core-avx2 -passes=slp-vectorizer -S | FileCheck %s --check-prefixes=CHECK,AVX,AVX256
6; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=skylake-avx512 -mattr=-prefer-256-bit -passes=slp-vectorizer -S | FileCheck %s --check-prefixes=CHECK,AVX,AVX512
7; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=skylake-avx512 -mattr=+prefer-256-bit -passes=slp-vectorizer -S | FileCheck %s --check-prefixes=CHECK,AVX,AVX256
8
9@srcA64 = common global [8 x double] zeroinitializer, align 64
10@srcB64 = common global [8 x double] zeroinitializer, align 64
11@srcC64 = common global [8 x double] zeroinitializer, align 64
12@srcA32 = common global [16 x float] zeroinitializer, align 64
13@srcB32 = common global [16 x float] zeroinitializer, align 64
14@srcC32 = common global [16 x float] zeroinitializer, align 64
15@dst64 = common global [8 x double] zeroinitializer, align 64
16@dst32 = common global [16 x float] zeroinitializer, align 64
17
18declare float @llvm.maxnum.f32(float, float)
19declare double @llvm.maxnum.f64(double, double)
20
21;
22; CHECK
23;
24
25define void @fmaxnum_2f64() #0 {
26; CHECK-LABEL: @fmaxnum_2f64(
27; CHECK-NEXT:    [[TMP1:%.*]] = load <2 x double>, ptr @srcA64, align 8
28; CHECK-NEXT:    [[TMP2:%.*]] = load <2 x double>, ptr @srcB64, align 8
29; CHECK-NEXT:    [[TMP3:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP1]], <2 x double> [[TMP2]])
30; CHECK-NEXT:    store <2 x double> [[TMP3]], ptr @dst64, align 8
31; CHECK-NEXT:    ret void
32;
33  %a0 = load double, ptr @srcA64, align 8
34  %a1 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 1), align 8
35  %b0 = load double, ptr @srcB64, align 8
36  %b1 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 1), align 8
37  %fmaxnum0 = call double @llvm.maxnum.f64(double %a0, double %b0)
38  %fmaxnum1 = call double @llvm.maxnum.f64(double %a1, double %b1)
39  store double %fmaxnum0, ptr @dst64, align 8
40  store double %fmaxnum1, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 1), align 8
41  ret void
42}
43
44define void @fmaxnum_4f64() #0 {
45; SSE-LABEL: @fmaxnum_4f64(
46; SSE-NEXT:    [[TMP1:%.*]] = load <2 x double>, ptr @srcA64, align 8
47; SSE-NEXT:    [[TMP2:%.*]] = load <2 x double>, ptr @srcB64, align 8
48; SSE-NEXT:    [[TMP3:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP1]], <2 x double> [[TMP2]])
49; SSE-NEXT:    store <2 x double> [[TMP3]], ptr @dst64, align 8
50; SSE-NEXT:    [[TMP4:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 2), align 8
51; SSE-NEXT:    [[TMP5:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 2), align 8
52; SSE-NEXT:    [[TMP6:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP4]], <2 x double> [[TMP5]])
53; SSE-NEXT:    store <2 x double> [[TMP6]], ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 2), align 8
54; SSE-NEXT:    ret void
55;
56; AVX-LABEL: @fmaxnum_4f64(
57; AVX-NEXT:    [[TMP1:%.*]] = load <4 x double>, ptr @srcA64, align 8
58; AVX-NEXT:    [[TMP2:%.*]] = load <4 x double>, ptr @srcB64, align 8
59; AVX-NEXT:    [[TMP3:%.*]] = call <4 x double> @llvm.maxnum.v4f64(<4 x double> [[TMP1]], <4 x double> [[TMP2]])
60; AVX-NEXT:    store <4 x double> [[TMP3]], ptr @dst64, align 8
61; AVX-NEXT:    ret void
62;
63  %a0 = load double, ptr @srcA64, align 8
64  %a1 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 1), align 8
65  %a2 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 2), align 8
66  %a3 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 3), align 8
67  %b0 = load double, ptr @srcB64, align 8
68  %b1 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 1), align 8
69  %b2 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 2), align 8
70  %b3 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 3), align 8
71  %fmaxnum0 = call double @llvm.maxnum.f64(double %a0, double %b0)
72  %fmaxnum1 = call double @llvm.maxnum.f64(double %a1, double %b1)
73  %fmaxnum2 = call double @llvm.maxnum.f64(double %a2, double %b2)
74  %fmaxnum3 = call double @llvm.maxnum.f64(double %a3, double %b3)
75  store double %fmaxnum0, ptr @dst64, align 8
76  store double %fmaxnum1, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 1), align 8
77  store double %fmaxnum2, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 2), align 8
78  store double %fmaxnum3, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 3), align 8
79  ret void
80}
81
82define void @fmaxnum_8f64() #0 {
83; SSE-LABEL: @fmaxnum_8f64(
84; SSE-NEXT:    [[TMP1:%.*]] = load <2 x double>, ptr @srcA64, align 4
85; SSE-NEXT:    [[TMP2:%.*]] = load <2 x double>, ptr @srcB64, align 4
86; SSE-NEXT:    [[TMP3:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP1]], <2 x double> [[TMP2]])
87; SSE-NEXT:    store <2 x double> [[TMP3]], ptr @dst64, align 4
88; SSE-NEXT:    [[TMP4:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 2), align 4
89; SSE-NEXT:    [[TMP5:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 2), align 4
90; SSE-NEXT:    [[TMP6:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP4]], <2 x double> [[TMP5]])
91; SSE-NEXT:    store <2 x double> [[TMP6]], ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 2), align 4
92; SSE-NEXT:    [[TMP7:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 4), align 4
93; SSE-NEXT:    [[TMP8:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 4), align 4
94; SSE-NEXT:    [[TMP9:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP7]], <2 x double> [[TMP8]])
95; SSE-NEXT:    store <2 x double> [[TMP9]], ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 4), align 4
96; SSE-NEXT:    [[TMP10:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 6), align 4
97; SSE-NEXT:    [[TMP11:%.*]] = load <2 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 6), align 4
98; SSE-NEXT:    [[TMP12:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[TMP10]], <2 x double> [[TMP11]])
99; SSE-NEXT:    store <2 x double> [[TMP12]], ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 6), align 4
100; SSE-NEXT:    ret void
101;
102; AVX256-LABEL: @fmaxnum_8f64(
103; AVX256-NEXT:    [[TMP1:%.*]] = load <4 x double>, ptr @srcA64, align 4
104; AVX256-NEXT:    [[TMP2:%.*]] = load <4 x double>, ptr @srcB64, align 4
105; AVX256-NEXT:    [[TMP3:%.*]] = call <4 x double> @llvm.maxnum.v4f64(<4 x double> [[TMP1]], <4 x double> [[TMP2]])
106; AVX256-NEXT:    store <4 x double> [[TMP3]], ptr @dst64, align 4
107; AVX256-NEXT:    [[TMP4:%.*]] = load <4 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 4), align 4
108; AVX256-NEXT:    [[TMP5:%.*]] = load <4 x double>, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 4), align 4
109; AVX256-NEXT:    [[TMP6:%.*]] = call <4 x double> @llvm.maxnum.v4f64(<4 x double> [[TMP4]], <4 x double> [[TMP5]])
110; AVX256-NEXT:    store <4 x double> [[TMP6]], ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 4), align 4
111; AVX256-NEXT:    ret void
112;
113; AVX512-LABEL: @fmaxnum_8f64(
114; AVX512-NEXT:    [[TMP1:%.*]] = load <8 x double>, ptr @srcA64, align 4
115; AVX512-NEXT:    [[TMP2:%.*]] = load <8 x double>, ptr @srcB64, align 4
116; AVX512-NEXT:    [[TMP3:%.*]] = call <8 x double> @llvm.maxnum.v8f64(<8 x double> [[TMP1]], <8 x double> [[TMP2]])
117; AVX512-NEXT:    store <8 x double> [[TMP3]], ptr @dst64, align 4
118; AVX512-NEXT:    ret void
119;
120  %a0 = load double, ptr @srcA64, align 4
121  %a1 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 1), align 4
122  %a2 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 2), align 4
123  %a3 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 3), align 4
124  %a4 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 4), align 4
125  %a5 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 5), align 4
126  %a6 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 6), align 4
127  %a7 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcA64, i32 0, i64 7), align 4
128  %b0 = load double, ptr @srcB64, align 4
129  %b1 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 1), align 4
130  %b2 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 2), align 4
131  %b3 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 3), align 4
132  %b4 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 4), align 4
133  %b5 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 5), align 4
134  %b6 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 6), align 4
135  %b7 = load double, ptr getelementptr inbounds ([8 x double], ptr @srcB64, i32 0, i64 7), align 4
136  %fmaxnum0 = call double @llvm.maxnum.f64(double %a0, double %b0)
137  %fmaxnum1 = call double @llvm.maxnum.f64(double %a1, double %b1)
138  %fmaxnum2 = call double @llvm.maxnum.f64(double %a2, double %b2)
139  %fmaxnum3 = call double @llvm.maxnum.f64(double %a3, double %b3)
140  %fmaxnum4 = call double @llvm.maxnum.f64(double %a4, double %b4)
141  %fmaxnum5 = call double @llvm.maxnum.f64(double %a5, double %b5)
142  %fmaxnum6 = call double @llvm.maxnum.f64(double %a6, double %b6)
143  %fmaxnum7 = call double @llvm.maxnum.f64(double %a7, double %b7)
144  store double %fmaxnum0, ptr @dst64, align 4
145  store double %fmaxnum1, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 1), align 4
146  store double %fmaxnum2, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 2), align 4
147  store double %fmaxnum3, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 3), align 4
148  store double %fmaxnum4, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 4), align 4
149  store double %fmaxnum5, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 5), align 4
150  store double %fmaxnum6, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 6), align 4
151  store double %fmaxnum7, ptr getelementptr inbounds ([8 x double], ptr @dst64, i32 0, i64 7), align 4
152  ret void
153}
154
155define void @fmaxnum_4f32() #0 {
156; CHECK-LABEL: @fmaxnum_4f32(
157; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x float>, ptr @srcA32, align 4
158; CHECK-NEXT:    [[TMP2:%.*]] = load <4 x float>, ptr @srcB32, align 4
159; CHECK-NEXT:    [[TMP3:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP1]], <4 x float> [[TMP2]])
160; CHECK-NEXT:    store <4 x float> [[TMP3]], ptr @dst32, align 4
161; CHECK-NEXT:    ret void
162;
163  %a0 = load float, ptr @srcA32, align 4
164  %a1 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 1), align 4
165  %a2 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 2), align 4
166  %a3 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 3), align 4
167  %b0 = load float, ptr @srcB32, align 4
168  %b1 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 1), align 4
169  %b2 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 2), align 4
170  %b3 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 3), align 4
171  %fmaxnum0 = call float @llvm.maxnum.f32(float %a0, float %b0)
172  %fmaxnum1 = call float @llvm.maxnum.f32(float %a1, float %b1)
173  %fmaxnum2 = call float @llvm.maxnum.f32(float %a2, float %b2)
174  %fmaxnum3 = call float @llvm.maxnum.f32(float %a3, float %b3)
175  store float %fmaxnum0, ptr @dst32, align 4
176  store float %fmaxnum1, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 1), align 4
177  store float %fmaxnum2, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 2), align 4
178  store float %fmaxnum3, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 3), align 4
179  ret void
180}
181
182define void @fmaxnum_8f32() #0 {
183; SSE-LABEL: @fmaxnum_8f32(
184; SSE-NEXT:    [[TMP1:%.*]] = load <4 x float>, ptr @srcA32, align 4
185; SSE-NEXT:    [[TMP2:%.*]] = load <4 x float>, ptr @srcB32, align 4
186; SSE-NEXT:    [[TMP3:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP1]], <4 x float> [[TMP2]])
187; SSE-NEXT:    store <4 x float> [[TMP3]], ptr @dst32, align 4
188; SSE-NEXT:    [[TMP4:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 4), align 4
189; SSE-NEXT:    [[TMP5:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 4), align 4
190; SSE-NEXT:    [[TMP6:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP4]], <4 x float> [[TMP5]])
191; SSE-NEXT:    store <4 x float> [[TMP6]], ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 4), align 4
192; SSE-NEXT:    ret void
193;
194; AVX-LABEL: @fmaxnum_8f32(
195; AVX-NEXT:    [[TMP1:%.*]] = load <8 x float>, ptr @srcA32, align 4
196; AVX-NEXT:    [[TMP2:%.*]] = load <8 x float>, ptr @srcB32, align 4
197; AVX-NEXT:    [[TMP3:%.*]] = call <8 x float> @llvm.maxnum.v8f32(<8 x float> [[TMP1]], <8 x float> [[TMP2]])
198; AVX-NEXT:    store <8 x float> [[TMP3]], ptr @dst32, align 4
199; AVX-NEXT:    ret void
200;
201  %a0 = load float, ptr @srcA32, align 4
202  %a1 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 1), align 4
203  %a2 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 2), align 4
204  %a3 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 3), align 4
205  %a4 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 4), align 4
206  %a5 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 5), align 4
207  %a6 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 6), align 4
208  %a7 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 7), align 4
209  %b0 = load float, ptr @srcB32, align 4
210  %b1 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 1), align 4
211  %b2 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 2), align 4
212  %b3 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 3), align 4
213  %b4 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 4), align 4
214  %b5 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 5), align 4
215  %b6 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 6), align 4
216  %b7 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 7), align 4
217  %fmaxnum0 = call float @llvm.maxnum.f32(float %a0, float %b0)
218  %fmaxnum1 = call float @llvm.maxnum.f32(float %a1, float %b1)
219  %fmaxnum2 = call float @llvm.maxnum.f32(float %a2, float %b2)
220  %fmaxnum3 = call float @llvm.maxnum.f32(float %a3, float %b3)
221  %fmaxnum4 = call float @llvm.maxnum.f32(float %a4, float %b4)
222  %fmaxnum5 = call float @llvm.maxnum.f32(float %a5, float %b5)
223  %fmaxnum6 = call float @llvm.maxnum.f32(float %a6, float %b6)
224  %fmaxnum7 = call float @llvm.maxnum.f32(float %a7, float %b7)
225  store float %fmaxnum0, ptr @dst32, align 4
226  store float %fmaxnum1, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 1), align 4
227  store float %fmaxnum2, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 2), align 4
228  store float %fmaxnum3, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 3), align 4
229  store float %fmaxnum4, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 4), align 4
230  store float %fmaxnum5, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 5), align 4
231  store float %fmaxnum6, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 6), align 4
232  store float %fmaxnum7, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 7), align 4
233  ret void
234}
235
236define void @fmaxnum_16f32() #0 {
237; SSE-LABEL: @fmaxnum_16f32(
238; SSE-NEXT:    [[TMP1:%.*]] = load <4 x float>, ptr @srcA32, align 4
239; SSE-NEXT:    [[TMP2:%.*]] = load <4 x float>, ptr @srcB32, align 4
240; SSE-NEXT:    [[TMP3:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP1]], <4 x float> [[TMP2]])
241; SSE-NEXT:    store <4 x float> [[TMP3]], ptr @dst32, align 4
242; SSE-NEXT:    [[TMP4:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 4), align 4
243; SSE-NEXT:    [[TMP5:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 4), align 4
244; SSE-NEXT:    [[TMP6:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP4]], <4 x float> [[TMP5]])
245; SSE-NEXT:    store <4 x float> [[TMP6]], ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 4), align 4
246; SSE-NEXT:    [[TMP7:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 8), align 4
247; SSE-NEXT:    [[TMP8:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 8), align 4
248; SSE-NEXT:    [[TMP9:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP7]], <4 x float> [[TMP8]])
249; SSE-NEXT:    store <4 x float> [[TMP9]], ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 8), align 4
250; SSE-NEXT:    [[TMP10:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 12), align 4
251; SSE-NEXT:    [[TMP11:%.*]] = load <4 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 12), align 4
252; SSE-NEXT:    [[TMP12:%.*]] = call <4 x float> @llvm.maxnum.v4f32(<4 x float> [[TMP10]], <4 x float> [[TMP11]])
253; SSE-NEXT:    store <4 x float> [[TMP12]], ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 12), align 4
254; SSE-NEXT:    ret void
255;
256; AVX256-LABEL: @fmaxnum_16f32(
257; AVX256-NEXT:    [[TMP1:%.*]] = load <8 x float>, ptr @srcA32, align 4
258; AVX256-NEXT:    [[TMP2:%.*]] = load <8 x float>, ptr @srcB32, align 4
259; AVX256-NEXT:    [[TMP3:%.*]] = call <8 x float> @llvm.maxnum.v8f32(<8 x float> [[TMP1]], <8 x float> [[TMP2]])
260; AVX256-NEXT:    store <8 x float> [[TMP3]], ptr @dst32, align 4
261; AVX256-NEXT:    [[TMP4:%.*]] = load <8 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 8), align 4
262; AVX256-NEXT:    [[TMP5:%.*]] = load <8 x float>, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 8), align 4
263; AVX256-NEXT:    [[TMP6:%.*]] = call <8 x float> @llvm.maxnum.v8f32(<8 x float> [[TMP4]], <8 x float> [[TMP5]])
264; AVX256-NEXT:    store <8 x float> [[TMP6]], ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 8), align 4
265; AVX256-NEXT:    ret void
266;
267; AVX512-LABEL: @fmaxnum_16f32(
268; AVX512-NEXT:    [[TMP1:%.*]] = load <16 x float>, ptr @srcA32, align 4
269; AVX512-NEXT:    [[TMP2:%.*]] = load <16 x float>, ptr @srcB32, align 4
270; AVX512-NEXT:    [[TMP3:%.*]] = call <16 x float> @llvm.maxnum.v16f32(<16 x float> [[TMP1]], <16 x float> [[TMP2]])
271; AVX512-NEXT:    store <16 x float> [[TMP3]], ptr @dst32, align 4
272; AVX512-NEXT:    ret void
273;
274  %a0  = load float, ptr @srcA32, align 4
275  %a1  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  1), align 4
276  %a2  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  2), align 4
277  %a3  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  3), align 4
278  %a4  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  4), align 4
279  %a5  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  5), align 4
280  %a6  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  6), align 4
281  %a7  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  7), align 4
282  %a8  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  8), align 4
283  %a9  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64  9), align 4
284  %a10 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 10), align 4
285  %a11 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 11), align 4
286  %a12 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 12), align 4
287  %a13 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 13), align 4
288  %a14 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 14), align 4
289  %a15 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcA32, i32 0, i64 15), align 4
290  %b0  = load float, ptr @srcB32, align 4
291  %b1  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  1), align 4
292  %b2  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  2), align 4
293  %b3  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  3), align 4
294  %b4  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  4), align 4
295  %b5  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  5), align 4
296  %b6  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  6), align 4
297  %b7  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  7), align 4
298  %b8  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  8), align 4
299  %b9  = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64  9), align 4
300  %b10 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 10), align 4
301  %b11 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 11), align 4
302  %b12 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 12), align 4
303  %b13 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 13), align 4
304  %b14 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 14), align 4
305  %b15 = load float, ptr getelementptr inbounds ([16 x float], ptr @srcB32, i32 0, i64 15), align 4
306  %fmaxnum0  = call float @llvm.maxnum.f32(float %a0 , float %b0 )
307  %fmaxnum1  = call float @llvm.maxnum.f32(float %a1 , float %b1 )
308  %fmaxnum2  = call float @llvm.maxnum.f32(float %a2 , float %b2 )
309  %fmaxnum3  = call float @llvm.maxnum.f32(float %a3 , float %b3 )
310  %fmaxnum4  = call float @llvm.maxnum.f32(float %a4 , float %b4 )
311  %fmaxnum5  = call float @llvm.maxnum.f32(float %a5 , float %b5 )
312  %fmaxnum6  = call float @llvm.maxnum.f32(float %a6 , float %b6 )
313  %fmaxnum7  = call float @llvm.maxnum.f32(float %a7 , float %b7 )
314  %fmaxnum8  = call float @llvm.maxnum.f32(float %a8 , float %b8 )
315  %fmaxnum9  = call float @llvm.maxnum.f32(float %a9 , float %b9 )
316  %fmaxnum10 = call float @llvm.maxnum.f32(float %a10, float %b10)
317  %fmaxnum11 = call float @llvm.maxnum.f32(float %a11, float %b11)
318  %fmaxnum12 = call float @llvm.maxnum.f32(float %a12, float %b12)
319  %fmaxnum13 = call float @llvm.maxnum.f32(float %a13, float %b13)
320  %fmaxnum14 = call float @llvm.maxnum.f32(float %a14, float %b14)
321  %fmaxnum15 = call float @llvm.maxnum.f32(float %a15, float %b15)
322  store float %fmaxnum0 , ptr @dst32, align 4
323  store float %fmaxnum1 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  1), align 4
324  store float %fmaxnum2 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  2), align 4
325  store float %fmaxnum3 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  3), align 4
326  store float %fmaxnum4 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  4), align 4
327  store float %fmaxnum5 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  5), align 4
328  store float %fmaxnum6 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  6), align 4
329  store float %fmaxnum7 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  7), align 4
330  store float %fmaxnum8 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  8), align 4
331  store float %fmaxnum9 , ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64  9), align 4
332  store float %fmaxnum10, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 10), align 4
333  store float %fmaxnum11, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 11), align 4
334  store float %fmaxnum12, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 12), align 4
335  store float %fmaxnum13, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 13), align 4
336  store float %fmaxnum14, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 14), align 4
337  store float %fmaxnum15, ptr getelementptr inbounds ([16 x float], ptr @dst32, i32 0, i64 15), align 4
338  ret void
339}
340
341define float @reduction_v4f32_fast(ptr %p) {
342; CHECK-LABEL: @reduction_v4f32_fast(
343; CHECK-NEXT:    [[TMP2:%.*]] = load <4 x float>, ptr [[P:%.*]], align 4
344; CHECK-NEXT:    [[TMP3:%.*]] = call fast float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[TMP2]])
345; CHECK-NEXT:    ret float [[TMP3]]
346;
347  %g1 = getelementptr inbounds float, ptr %p, i64 1
348  %g2 = getelementptr inbounds float, ptr %p, i64 2
349  %g3 = getelementptr inbounds float, ptr %p, i64 3
350  %t0 = load float, ptr %p, align 4
351  %t1 = load float, ptr %g1, align 4
352  %t2 = load float, ptr %g2, align 4
353  %t3 = load float, ptr %g3, align 4
354  %m1 = tail call fast float @llvm.maxnum.f32(float %t1, float %t0)
355  %m2 = tail call fast float @llvm.maxnum.f32(float %t2, float %m1)
356  %m3 = tail call fast float @llvm.maxnum.f32(float %t3, float %m2)
357  ret float %m3
358}
359
360define float @reduction_v4f32_nnan(ptr %p) {
361; CHECK-LABEL: @reduction_v4f32_nnan(
362; CHECK-NEXT:    [[TMP2:%.*]] = load <4 x float>, ptr [[P:%.*]], align 4
363; CHECK-NEXT:    [[TMP3:%.*]] = call nnan float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[TMP2]])
364; CHECK-NEXT:    ret float [[TMP3]]
365;
366  %g1 = getelementptr inbounds float, ptr %p, i64 1
367  %g2 = getelementptr inbounds float, ptr %p, i64 2
368  %g3 = getelementptr inbounds float, ptr %p, i64 3
369  %t0 = load float, ptr %p, align 4
370  %t1 = load float, ptr %g1, align 4
371  %t2 = load float, ptr %g2, align 4
372  %t3 = load float, ptr %g3, align 4
373  %m1 = tail call nnan float @llvm.maxnum.f32(float %t1, float %t0)
374  %m2 = tail call nnan float @llvm.maxnum.f32(float %t2, float %m1)
375  %m3 = tail call nnan float @llvm.maxnum.f32(float %t3, float %m2)
376  ret float %m3
377}
378
379; Negative test - must have nnan.
380
381define float @reduction_v4f32_not_fast(ptr %p) {
382; CHECK-LABEL: @reduction_v4f32_not_fast(
383; CHECK-NEXT:    [[G1:%.*]] = getelementptr inbounds float, ptr [[P:%.*]], i64 1
384; CHECK-NEXT:    [[G2:%.*]] = getelementptr inbounds float, ptr [[P]], i64 2
385; CHECK-NEXT:    [[G3:%.*]] = getelementptr inbounds float, ptr [[P]], i64 3
386; CHECK-NEXT:    [[T0:%.*]] = load float, ptr [[P]], align 4
387; CHECK-NEXT:    [[T1:%.*]] = load float, ptr [[G1]], align 4
388; CHECK-NEXT:    [[T2:%.*]] = load float, ptr [[G2]], align 4
389; CHECK-NEXT:    [[T3:%.*]] = load float, ptr [[G3]], align 4
390; CHECK-NEXT:    [[M1:%.*]] = tail call float @llvm.maxnum.f32(float [[T1]], float [[T0]])
391; CHECK-NEXT:    [[M2:%.*]] = tail call float @llvm.maxnum.f32(float [[T2]], float [[M1]])
392; CHECK-NEXT:    [[M3:%.*]] = tail call float @llvm.maxnum.f32(float [[T3]], float [[M2]])
393; CHECK-NEXT:    ret float [[M3]]
394;
395  %g1 = getelementptr inbounds float, ptr %p, i64 1
396  %g2 = getelementptr inbounds float, ptr %p, i64 2
397  %g3 = getelementptr inbounds float, ptr %p, i64 3
398  %t0 = load float, ptr %p, align 4
399  %t1 = load float, ptr %g1, align 4
400  %t2 = load float, ptr %g2, align 4
401  %t3 = load float, ptr %g3, align 4
402  %m1 = tail call float @llvm.maxnum.f32(float %t1, float %t0)
403  %m2 = tail call float @llvm.maxnum.f32(float %t2, float %m1)
404  %m3 = tail call float @llvm.maxnum.f32(float %t3, float %m2)
405  ret float %m3
406}
407
408define float @reduction_v8f32_fast(ptr %p) {
409; CHECK-LABEL: @reduction_v8f32_fast(
410; CHECK-NEXT:    [[TMP2:%.*]] = load <8 x float>, ptr [[P:%.*]], align 4
411; CHECK-NEXT:    [[TMP3:%.*]] = call fast float @llvm.vector.reduce.fmax.v8f32(<8 x float> [[TMP2]])
412; CHECK-NEXT:    ret float [[TMP3]]
413;
414  %g1 = getelementptr inbounds float, ptr %p, i64 1
415  %g2 = getelementptr inbounds float, ptr %p, i64 2
416  %g3 = getelementptr inbounds float, ptr %p, i64 3
417  %g4 = getelementptr inbounds float, ptr %p, i64 4
418  %g5 = getelementptr inbounds float, ptr %p, i64 5
419  %g6 = getelementptr inbounds float, ptr %p, i64 6
420  %g7 = getelementptr inbounds float, ptr %p, i64 7
421  %t0 = load float, ptr %p, align 4
422  %t1 = load float, ptr %g1, align 4
423  %t2 = load float, ptr %g2, align 4
424  %t3 = load float, ptr %g3, align 4
425  %t4 = load float, ptr %g4, align 4
426  %t5 = load float, ptr %g5, align 4
427  %t6 = load float, ptr %g6, align 4
428  %t7 = load float, ptr %g7, align 4
429  %m1 = tail call fast float @llvm.maxnum.f32(float %t1, float %t0)
430  %m2 = tail call fast float @llvm.maxnum.f32(float %t2, float %m1)
431  %m3 = tail call fast float @llvm.maxnum.f32(float %t3, float %m2)
432  %m4 = tail call fast float @llvm.maxnum.f32(float %t4, float %m3)
433  %m5 = tail call fast float @llvm.maxnum.f32(float %m4, float %t6)
434  %m6 = tail call fast float @llvm.maxnum.f32(float %m5, float %t5)
435  %m7 = tail call fast float @llvm.maxnum.f32(float %m6, float %t7)
436  ret float %m7
437}
438
439define double @reduction_v2f64_fast(ptr %p) {
440; CHECK-LABEL: @reduction_v2f64_fast(
441; CHECK-NEXT:    [[G1:%.*]] = getelementptr inbounds double, ptr [[P:%.*]], i64 1
442; CHECK-NEXT:    [[T0:%.*]] = load double, ptr [[P]], align 4
443; CHECK-NEXT:    [[T1:%.*]] = load double, ptr [[G1]], align 4
444; CHECK-NEXT:    [[M1:%.*]] = tail call fast double @llvm.maxnum.f64(double [[T1]], double [[T0]])
445; CHECK-NEXT:    ret double [[M1]]
446;
447  %g1 = getelementptr inbounds double, ptr %p, i64 1
448  %t0 = load double, ptr %p, align 4
449  %t1 = load double, ptr %g1, align 4
450  %m1 = tail call fast double @llvm.maxnum.f64(double %t1, double %t0)
451  ret double %m1
452}
453
454define double @reduction_v4f64_fast(ptr %p) {
455; CHECK-LABEL: @reduction_v4f64_fast(
456; CHECK-NEXT:    [[TMP2:%.*]] = load <4 x double>, ptr [[P:%.*]], align 4
457; CHECK-NEXT:    [[TMP3:%.*]] = call fast double @llvm.vector.reduce.fmax.v4f64(<4 x double> [[TMP2]])
458; CHECK-NEXT:    ret double [[TMP3]]
459;
460  %g1 = getelementptr inbounds double, ptr %p, i64 1
461  %g2 = getelementptr inbounds double, ptr %p, i64 2
462  %g3 = getelementptr inbounds double, ptr %p, i64 3
463  %t0 = load double, ptr %p, align 4
464  %t1 = load double, ptr %g1, align 4
465  %t2 = load double, ptr %g2, align 4
466  %t3 = load double, ptr %g3, align 4
467  %m1 = tail call fast double @llvm.maxnum.f64(double %t1, double %t0)
468  %m2 = tail call fast double @llvm.maxnum.f64(double %t2, double %m1)
469  %m3 = tail call fast double @llvm.maxnum.f64(double %t3, double %m2)
470  ret double %m3
471}
472
473; Negative test - must have nnan.
474
475define double @reduction_v4f64_wrong_fmf(ptr %p) {
476; CHECK-LABEL: @reduction_v4f64_wrong_fmf(
477; CHECK-NEXT:    [[G1:%.*]] = getelementptr inbounds double, ptr [[P:%.*]], i64 1
478; CHECK-NEXT:    [[G2:%.*]] = getelementptr inbounds double, ptr [[P]], i64 2
479; CHECK-NEXT:    [[G3:%.*]] = getelementptr inbounds double, ptr [[P]], i64 3
480; CHECK-NEXT:    [[T0:%.*]] = load double, ptr [[P]], align 4
481; CHECK-NEXT:    [[T1:%.*]] = load double, ptr [[G1]], align 4
482; CHECK-NEXT:    [[T2:%.*]] = load double, ptr [[G2]], align 4
483; CHECK-NEXT:    [[T3:%.*]] = load double, ptr [[G3]], align 4
484; CHECK-NEXT:    [[M1:%.*]] = tail call ninf nsz double @llvm.maxnum.f64(double [[T1]], double [[T0]])
485; CHECK-NEXT:    [[M2:%.*]] = tail call ninf nsz double @llvm.maxnum.f64(double [[T2]], double [[M1]])
486; CHECK-NEXT:    [[M3:%.*]] = tail call ninf nsz double @llvm.maxnum.f64(double [[T3]], double [[M2]])
487; CHECK-NEXT:    ret double [[M3]]
488;
489  %g1 = getelementptr inbounds double, ptr %p, i64 1
490  %g2 = getelementptr inbounds double, ptr %p, i64 2
491  %g3 = getelementptr inbounds double, ptr %p, i64 3
492  %t0 = load double, ptr %p, align 4
493  %t1 = load double, ptr %g1, align 4
494  %t2 = load double, ptr %g2, align 4
495  %t3 = load double, ptr %g3, align 4
496  %m1 = tail call ninf nsz double @llvm.maxnum.f64(double %t1, double %t0)
497  %m2 = tail call ninf nsz double @llvm.maxnum.f64(double %t2, double %m1)
498  %m3 = tail call ninf nsz double @llvm.maxnum.f64(double %t3, double %m2)
499  ret double %m3
500}
501
502attributes #0 = { nounwind }
503