Skip to content

Commit 90f25cd

Browse files
committed
test auto vectorize
1 parent 77a9aad commit 90f25cd

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

clang/test/CodeGen/fmaxnum_fminnum_use_nsz.c

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -triple x86_64 %s -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK
2-
// RUN: %clang_cc1 -ffp-exception-behavior=strict -triple x86_64 %s -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-STRICT
1+
// RUN: %clang_cc1 -vectorize-loops -vectorize-slp -O3 -triple x86_64 %s -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK
2+
// RUN: %clang_cc1 -vectorize-loops -vectorize-slp -O3 -ffp-exception-behavior=strict -DENSTRICT=1 -triple x86_64 %s -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-STRICT
33

44
float fminf (float, float);
55
double fmin (double, double);
@@ -18,6 +18,20 @@ float fmin32(float a, float b) {
1818
float fmin32b(float a, float b) {
1919
return __builtin_fminf(a, b);
2020
}
21+
#if !defined(ENSTRICT)
22+
// CHECK: call nsz <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
23+
float *pfmin32(float* a, float* b, float* restrict c) {
24+
for (int i=0; i<4; i++)
25+
c[i] = fminf(a[i], b[i]);
26+
return c;
27+
}
28+
// CHECK: call nsz <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
29+
float *pfmin32b(float* a, float* b, float* restrict c) {
30+
for (int i=0; i<4; i++)
31+
c[i] = __builtin_fminf(a[i], b[i]);
32+
return c;
33+
}
34+
#endif
2135
// CHECK: call nsz double @llvm.minnum.f64
2236
// CHECK-STRICT: call nsz double @llvm.experimental.constrained.minnum.f64{{.*}} #2
2337
float fmin64(double a, double b) {
@@ -28,6 +42,20 @@ float fmin64(double a, double b) {
2842
float fmin64b(double a, double b) {
2943
return __builtin_fmin(a, b);
3044
}
45+
#if !defined(ENSTRICT)
46+
// CHECK: call nsz <2 x double> @llvm.minnum.v2f64(<2 x double> %0, <2 x double> %1)
47+
double *pfmin64(double* a, double* b, double* restrict c) {
48+
for (int i=0; i<2; i++)
49+
c[i] = fmin(a[i], b[i]);
50+
return c;
51+
}
52+
// CHECK: call nsz <2 x double> @llvm.minnum.v2f64(<2 x double> %0, <2 x double> %1)
53+
double *pfmin64b(double* a, double* b, double* restrict c) {
54+
for (int i=0; i<2; i++)
55+
c[i] = __builtin_fmin(a[i], b[i]);
56+
return c;
57+
}
58+
#endif
3159
// CHECK: call nsz x86_fp80 @llvm.minnum.f80
3260
// CHECK-STRICT: call nsz x86_fp80 @llvm.experimental.constrained.minnum.f80{{.*}} #2
3361
float fmin80(long double a, long double b) {
@@ -48,6 +76,20 @@ float fmax32(float a, float b) {
4876
float fmax32b(float a, float b) {
4977
return __builtin_fmaxf(a, b);
5078
}
79+
#if !defined(ENSTRICT)
80+
// CHECK: call nsz <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
81+
float *pfmax32(float* a, float* b, float* restrict c) {
82+
for (int i=0; i<4; i++)
83+
c[i] = fmaxf(a[i], b[i]);
84+
return c;
85+
}
86+
// CHECK: call nsz <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
87+
float *pfmax32b(float* a, float* b, float* restrict c) {
88+
for (int i=0; i<4; i++)
89+
c[i] = __builtin_fmaxf(a[i], b[i]);
90+
return c;
91+
}
92+
#endif
5193
// CHECK: call nsz double @llvm.maxnum.f64
5294
// CHECK-STRICT: call nsz double @llvm.experimental.constrained.maxnum.f64{{.*}} #2
5395
float fmax64(double a, double b) {
@@ -63,6 +105,20 @@ float fmax64b(double a, double b) {
63105
float fmax3(long double a, long double b) {
64106
return fmaxl(a, b);
65107
}
108+
#if !defined(ENSTRICT)
109+
// CHECK: call nsz <2 x double> @llvm.maxnum.v2f64(<2 x double> %0, <2 x double> %1)
110+
double *pfmax64(double* a, double* b, double* restrict c) {
111+
for (int i=0; i<2; i++)
112+
c[i] = fmax(a[i], b[i]);
113+
return c;
114+
}
115+
// CHECK: call nsz <2 x double> @llvm.maxnum.v2f64(<2 x double> %0, <2 x double> %1)
116+
double *pfmax64b(double* a, double* b, double* restrict c) {
117+
for (int i=0; i<2; i++)
118+
c[i] = __builtin_fmax(a[i], b[i]);
119+
return c;
120+
}
121+
#endif
66122
// CHECK: call nsz x86_fp80 @llvm.maxnum.f80
67123
// CHECK-STRICT: call nsz x86_fp80 @llvm.experimental.constrained.maxnum.f80{{.*}} #2
68124
float fmax80b(long double a, long double b) {

0 commit comments

Comments
 (0)