Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/builtins-elementwise.c

raw
1 // RUN: %clang_cc1 -triple aarch64-none-linux-android24 -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -triple aarch64-none-linux-android24 -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -triple aarch64-none-linux-android24 -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 typedef int vint4 __attribute__((ext_vector_type(4)));
9 typedef float vfloat4 __attribute__((ext_vector_type(4)));
10 typedef double vdouble4 __attribute__((ext_vector_type(4)));
11
12 void test_builtin_elementwise_acos(float f, double d, vfloat4 vf4,
13 vdouble4 vd4) {
14 // CIR-LABEL: test_builtin_elementwise_acos
15 // LLVM-LABEL: test_builtin_elementwise_acos
16 // OGCG-LABEL: test_builtin_elementwise_acos
17
18 // CIR: %{{.*}} = cir.acos %{{.*}} : !cir.float
19 // LLVM: %{{.*}} = call float @llvm.acos.f32(float %{{.*}})
20 // OGCG: %{{.*}} = call float @llvm.acos.f32(float %{{.*}})
21 f = __builtin_elementwise_acos(f);
22
23 // CIR: %{{.*}} = cir.acos %{{.*}} : !cir.double
24 // LLVM: %{{.*}} = call double @llvm.acos.f64(double %{{.*}})
25 // OGCG: %{{.*}} = call double @llvm.acos.f64(double %{{.*}})
26 d = __builtin_elementwise_acos(d);
27
28 // CIR: %{{.*}} = cir.acos %{{.*}} : !cir.vector<4 x !cir.float>
29 // LLVM: %{{.*}} = call <4 x float> @llvm.acos.v4f32(<4 x float> %{{.*}})
30 // OGCG: %{{.*}} = call <4 x float> @llvm.acos.v4f32(<4 x float> %{{.*}})
31 vf4 = __builtin_elementwise_acos(vf4);
32
33 // CIR: %{{.*}} = cir.acos %{{.*}} : !cir.vector<4 x !cir.double>
34 // LLVM: %{{.*}} = call <4 x double> @llvm.acos.v4f64(<4 x double> %{{.*}})
35 // OGCG: %{{.*}} = call <4 x double> @llvm.acos.v4f64(<4 x double> %{{.*}})
36 vd4 = __builtin_elementwise_acos(vd4);
37 }
38
39 void test_builtin_elementwise_asin(float f, double d, vfloat4 vf4,
40 vdouble4 vd4) {
41 // CIR-LABEL: test_builtin_elementwise_asin
42 // LLVM-LABEL: test_builtin_elementwise_asin
43 // OGCG-LABEL: test_builtin_elementwise_asin
44
45 // CIR: %{{.*}} = cir.asin %{{.*}} : !cir.float
46 // LLVM: %{{.*}} = call float @llvm.asin.f32(float %{{.*}})
47 // OGCG: %{{.*}} = call float @llvm.asin.f32(float %{{.*}})
48 f = __builtin_elementwise_asin(f);
49
50 // CIR: %{{.*}} = cir.asin %{{.*}} : !cir.double
51 // LLVM: %{{.*}} = call double @llvm.asin.f64(double %{{.*}})
52 // OGCG: %{{.*}} = call double @llvm.asin.f64(double %{{.*}})
53 d = __builtin_elementwise_asin(d);
54
55 // CIR: %{{.*}} = cir.asin %{{.*}} : !cir.vector<4 x !cir.float>
56 // LLVM: %{{.*}} = call <4 x float> @llvm.asin.v4f32(<4 x float> %{{.*}})
57 // OGCG: %{{.*}} = call <4 x float> @llvm.asin.v4f32(<4 x float> %{{.*}})
58 vf4 = __builtin_elementwise_asin(vf4);
59
60 // CIR: %{{.*}} = cir.asin %{{.*}} : !cir.vector<4 x !cir.double>
61 // LLVM: %{{.*}} = call <4 x double> @llvm.asin.v4f64(<4 x double> %{{.*}})
62 // OGCG: %{{.*}} = call <4 x double> @llvm.asin.v4f64(<4 x double> %{{.*}})
63 vd4 = __builtin_elementwise_asin(vd4);
64 }
65
66 void test_builtin_elementwise_atan(float f, double d, vfloat4 vf4,
67 vdouble4 vd4) {
68 // CIR-LABEL: test_builtin_elementwise_atan
69 // LLVM-LABEL: test_builtin_elementwise_atan
70 // OGCG-LABEL: test_builtin_elementwise_atan
71
72 // CIR: %{{.*}} = cir.atan %{{.*}} : !cir.float
73 // LLVM: %{{.*}} = call float @llvm.atan.f32(float %{{.*}})
74 // OGCG: %{{.*}} = call float @llvm.atan.f32(float %{{.*}})
75 f = __builtin_elementwise_atan(f);
76
77 // CIR: %{{.*}} = cir.atan %{{.*}} : !cir.double
78 // LLVM: %{{.*}} = call double @llvm.atan.f64(double %{{.*}})
79 // OGCG: %{{.*}} = call double @llvm.atan.f64(double %{{.*}})
80 d = __builtin_elementwise_atan(d);
81
82 // CIR: %{{.*}} = cir.atan %{{.*}} : !cir.vector<4 x !cir.float>
83 // LLVM: %{{.*}} = call <4 x float> @llvm.atan.v4f32(<4 x float> %{{.*}})
84 // OGCG: %{{.*}} = call <4 x float> @llvm.atan.v4f32(<4 x float> %{{.*}})
85 vf4 = __builtin_elementwise_atan(vf4);
86
87 // CIR: %{{.*}} = cir.atan %{{.*}} : !cir.vector<4 x !cir.double>
88 // LLVM: %{{.*}} = call <4 x double> @llvm.atan.v4f64(<4 x double> %{{.*}})
89 // OGCG: %{{.*}} = call <4 x double> @llvm.atan.v4f64(<4 x double> %{{.*}})
90 vd4 = __builtin_elementwise_atan(vd4);
91 }
92
93 void test_builtin_elementwise_cos(float f, double d, vfloat4 vf4,
94 vdouble4 vd4) {
95 // CIR-LABEL: test_builtin_elementwise_cos
96 // LLVM-LABEL: test_builtin_elementwise_cos
97 // OGCG-LABEL: test_builtin_elementwise_cos
98
99 // CIR: {{%.*}} = cir.cos {{%.*}} : !cir.float
100 // LLVM: {{%.*}} = call float @llvm.cos.f32(float {{%.*}})
101 // OGCG: {{%.*}} = call float @llvm.cos.f32(float {{%.*}})
102 f = __builtin_elementwise_cos(f);
103
104 // CIR: {{%.*}} = cir.cos {{%.*}} : !cir.double
105 // LLVM: {{%.*}} = call double @llvm.cos.f64(double {{%.*}})
106 // OGCG: {{%.*}} = call double @llvm.cos.f64(double {{%.*}})
107 d = __builtin_elementwise_cos(d);
108
109 // CIR: {{%.*}} = cir.cos {{%.*}} : !cir.vector<4 x !cir.float>
110 // LLVM: {{%.*}} = call <4 x float> @llvm.cos.v4f32(<4 x float> {{%.*}})
111 // OGCG: {{%.*}} = call <4 x float> @llvm.cos.v4f32(<4 x float> {{%.*}})
112 vf4 = __builtin_elementwise_cos(vf4);
113
114 // CIR: {{%.*}} = cir.cos {{%.*}} : !cir.vector<4 x !cir.double>
115 // LLVM: {{%.*}} = call <4 x double> @llvm.cos.v4f64(<4 x double> {{%.*}})
116 // OGCG: {{%.*}} = call <4 x double> @llvm.cos.v4f64(<4 x double> {{%.*}})
117 vd4 = __builtin_elementwise_cos(vd4);
118 }