Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / builtins-elementwise-math.cpp
blob44a44ab055e99720ca026109d3115bb8029d5c5d
1 // RUN: %clang_cc1 %s -std=c++17 -pedantic -verify -triple=x86_64-apple-darwin9
3 // Simple is_const implementation.
4 struct true_type {
5 static const bool value = true;
6 };
8 struct false_type {
9 static const bool value = false;
12 template <class T> struct is_const : false_type {};
13 template <class T> struct is_const<const T> : true_type {};
15 // expected-no-diagnostics
17 void test_builtin_elementwise_abs() {
18 const int a = 2;
19 int b = 1;
20 static_assert(!is_const<decltype(__builtin_elementwise_abs(a))>::value);
21 static_assert(!is_const<decltype(__builtin_elementwise_abs(b))>::value);
24 void test_builtin_elementwise_abs_fp() {
25 const float a = -2.0f;
26 float b = 1.0f;
27 static_assert(!is_const<decltype(__builtin_elementwise_abs(a))>::value);
28 static_assert(!is_const<decltype(__builtin_elementwise_abs(b))>::value);
31 void test_builtin_elementwise_add_sat() {
32 const int a = 2;
33 int b = 1;
34 static_assert(!is_const<decltype(__builtin_elementwise_add_sat(a, b))>::value);
35 static_assert(!is_const<decltype(__builtin_elementwise_add_sat(b, a))>::value);
36 static_assert(!is_const<decltype(__builtin_elementwise_add_sat(a, a))>::value);
39 void test_builtin_elementwise_sub_sat() {
40 const int a = 2;
41 int b = 1;
42 static_assert(!is_const<decltype(__builtin_elementwise_sub_sat(a, b))>::value);
43 static_assert(!is_const<decltype(__builtin_elementwise_sub_sat(b, a))>::value);
44 static_assert(!is_const<decltype(__builtin_elementwise_sub_sat(a, a))>::value);
47 void test_builtin_elementwise_max() {
48 const int a = 2;
49 int b = 1;
50 static_assert(!is_const<decltype(__builtin_elementwise_max(a, b))>::value);
51 static_assert(!is_const<decltype(__builtin_elementwise_max(b, a))>::value);
52 static_assert(!is_const<decltype(__builtin_elementwise_max(a, a))>::value);
55 void test_builtin_elementwise_min() {
56 const int a = 2;
57 int b = 1;
58 static_assert(!is_const<decltype(__builtin_elementwise_min(a, b))>::value);
59 static_assert(!is_const<decltype(__builtin_elementwise_min(b, a))>::value);
60 static_assert(!is_const<decltype(__builtin_elementwise_min(a, a))>::value);
63 void test_builtin_elementwise_max_fp() {
64 const float a = 2.0f;
65 float b = 1.0f;
66 static_assert(!is_const<decltype(__builtin_elementwise_max(a, b))>::value);
67 static_assert(!is_const<decltype(__builtin_elementwise_max(b, a))>::value);
68 static_assert(!is_const<decltype(__builtin_elementwise_max(a, a))>::value);
71 void test_builtin_elementwise_min_fp() {
72 const float a = 2.0f;
73 float b = 1.0f;
74 static_assert(!is_const<decltype(__builtin_elementwise_min(a, b))>::value);
75 static_assert(!is_const<decltype(__builtin_elementwise_min(b, a))>::value);
76 static_assert(!is_const<decltype(__builtin_elementwise_min(a, a))>::value);
79 void test_builtin_elementwise_ceil() {
80 const float a = 42.0;
81 float b = 42.3;
82 static_assert(!is_const<decltype(__builtin_elementwise_ceil(a))>::value);
83 static_assert(!is_const<decltype(__builtin_elementwise_ceil(b))>::value);
86 void test_builtin_elementwise_cos() {
87 const float a = 42.0;
88 float b = 42.3;
89 static_assert(!is_const<decltype(__builtin_elementwise_cos(a))>::value);
90 static_assert(!is_const<decltype(__builtin_elementwise_cos(b))>::value);
93 void test_builtin_elementwise_exp() {
94 const float a = 42.0;
95 float b = 42.3;
96 static_assert(!is_const<decltype(__builtin_elementwise_exp(a))>::value);
97 static_assert(!is_const<decltype(__builtin_elementwise_exp(b))>::value);
100 void test_builtin_elementwise_exp2() {
101 const float a = 42.0;
102 float b = 42.3;
103 static_assert(!is_const<decltype(__builtin_elementwise_exp2(a))>::value);
104 static_assert(!is_const<decltype(__builtin_elementwise_exp2(b))>::value);
107 void test_builtin_elementwise_sin() {
108 const float a = 42.0;
109 float b = 42.3;
110 static_assert(!is_const<decltype(__builtin_elementwise_sin(a))>::value);
111 static_assert(!is_const<decltype(__builtin_elementwise_sin(b))>::value);
114 void test_builtin_elementwise_sqrt() {
115 const float a = 42.0;
116 float b = 42.3;
117 static_assert(!is_const<decltype(__builtin_elementwise_sqrt(a))>::value);
118 static_assert(!is_const<decltype(__builtin_elementwise_sqrt(b))>::value);
121 void test_builtin_elementwise_log() {
122 const float a = 42.0;
123 float b = 42.3;
124 static_assert(!is_const<decltype(__builtin_elementwise_log(a))>::value);
125 static_assert(!is_const<decltype(__builtin_elementwise_log(b))>::value);
128 void test_builtin_elementwise_log10() {
129 const float a = 42.0;
130 float b = 42.3;
131 static_assert(!is_const<decltype(__builtin_elementwise_log10(a))>::value);
132 static_assert(!is_const<decltype(__builtin_elementwise_log10(b))>::value);
135 void test_builtin_elementwise_log2() {
136 const float a = 42.0;
137 float b = 42.3;
138 static_assert(!is_const<decltype(__builtin_elementwise_log2(a))>::value);
139 static_assert(!is_const<decltype(__builtin_elementwise_log2(b))>::value);
142 void test_builtin_elementwise_rint() {
143 const float a = 42.5;
144 float b = 42.3;
145 static_assert(!is_const<decltype(__builtin_elementwise_rint(a))>::value);
146 static_assert(!is_const<decltype(__builtin_elementwise_rint(b))>::value);
149 void test_builtin_elementwise_nearbyint() {
150 const float a = 42.5;
151 float b = 42.3;
152 static_assert(!is_const<decltype(__builtin_elementwise_nearbyint(a))>::value);
153 static_assert(!is_const<decltype(__builtin_elementwise_nearbyint(b))>::value);
156 void test_builtin_elementwise_round() {
157 const float a = 42.5;
158 float b = 42.3;
159 static_assert(!is_const<decltype(__builtin_elementwise_round(a))>::value);
160 static_assert(!is_const<decltype(__builtin_elementwise_round(b))>::value);
163 void test_builtin_elementwise_roundeven() {
164 const float a = 42.5;
165 float b = 42.3;
166 static_assert(!is_const<decltype(__builtin_elementwise_roundeven(a))>::value);
167 static_assert(!is_const<decltype(__builtin_elementwise_roundeven(b))>::value);
170 void test_builtin_elementwise_trunc() {
171 const float a = 42.5;
172 float b = 42.3;
173 static_assert(!is_const<decltype(__builtin_elementwise_trunc(a))>::value);
174 static_assert(!is_const<decltype(__builtin_elementwise_trunc(b))>::value);
177 void test_builtin_elementwise_floor() {
178 const float a = 42.5;
179 float b = 42.3;
180 static_assert(!is_const<decltype(__builtin_elementwise_floor(a))>::value);
181 static_assert(!is_const<decltype(__builtin_elementwise_floor(b))>::value);
184 void test_builtin_elementwise_canonicalize() {
185 const float a = 42.5;
186 float b = 42.3;
187 static_assert(!is_const<decltype(__builtin_elementwise_canonicalize(a))>::value);
188 static_assert(!is_const<decltype(__builtin_elementwise_canonicalize(b))>::value);
191 void test_builtin_elementwise_copysign() {
192 const float a = 2.0f;
193 float b = -4.0f;
194 static_assert(!is_const<decltype(__builtin_elementwise_copysign(a, b))>::value);
195 static_assert(!is_const<decltype(__builtin_elementwise_copysign(b, a))>::value);
196 static_assert(!is_const<decltype(__builtin_elementwise_copysign(a, a))>::value);
199 void test_builtin_elementwise_fma() {
200 const float a = 2.0f;
201 float b = -4.0f;
202 float c = 1.0f;
203 static_assert(!is_const<decltype(__builtin_elementwise_fma(a, a, a))>::value);
204 static_assert(!is_const<decltype(__builtin_elementwise_fma(a, b, c))>::value);
205 static_assert(!is_const<decltype(__builtin_elementwise_fma(b, a, c))>::value);
206 static_assert(!is_const<decltype(__builtin_elementwise_fma(c, c, c))>::value);
209 void test_builtin_elementwise_pow() {
210 const double a = 2;
211 double b = 1;
212 static_assert(!is_const<decltype(__builtin_elementwise_pow(a, b))>::value);
213 static_assert(!is_const<decltype(__builtin_elementwise_pow(b, a))>::value);
214 static_assert(!is_const<decltype(__builtin_elementwise_pow(a, a))>::value);
217 void test_builtin_elementwise_bitreverse() {
218 const int a = 2;
219 int b = 1;
220 static_assert(!is_const<decltype(__builtin_elementwise_bitreverse(a))>::value);
221 static_assert(!is_const<decltype(__builtin_elementwise_bitreverse(b))>::value);