1414
1515static_assert (LIBC_HAS_VECTOR_TYPE, " compiler needs ext_vector_type support" );
1616
17- using namespace LIBC_NAMESPACE ::cpp ;
17+ using namespace LIBC_NAMESPACE ;
1818
1919TEST (LlvmLibcSIMDTest, Basic) {}
2020TEST (LlvmLibcSIMDTest, VectorCreation) {
21- simd<int > v1 = splat (5 );
22- simd<int > v2 = iota<int >();
21+ cpp:: simd<int > v1 = cpp:: splat (5 );
22+ cpp:: simd<int > v2 = cpp:: iota<int >();
2323
2424 EXPECT_EQ (v1[0 ], 5 );
2525 EXPECT_EQ (v2[0 ], 0 );
2626}
2727
2828TEST (LlvmLibcSIMDTest, TypeTraits) {
29- simd<int > v1 = splat (0 );
29+ cpp:: simd<int > v1 = cpp:: splat (0 );
3030
31- static_assert (is_simd_v<decltype (v1)>, " v1 should be a SIMD type" );
32- static_assert (!is_simd_v<int >, " int is not a SIMD type" );
33- static_assert (is_simd_mask_v<simd<bool , 4 >>, " should be a SIMD mask" );
31+ static_assert (cpp::is_simd_v<decltype (v1)>, " v1 should be a SIMD type" );
32+ static_assert (!cpp::is_simd_v<int >, " int is not a SIMD type" );
33+ static_assert (cpp::is_simd_mask_v<cpp::simd<bool , 4 >>,
34+ " should be a SIMD mask" );
3435
35- using Elem = simd_element_type_t <decltype (v1)>;
36- static_assert (is_same_v<Elem, int >, " element type should be int" );
36+ using Elem = cpp:: simd_element_type_t <decltype (v1)>;
37+ static_assert (cpp:: is_same_v<Elem, int >, " element type should be int" );
3738}
3839
3940TEST (LlvmLibcSIMDTest, ElementwiseOperations) {
40- simd<int > vi1 = splat (1 );
41- simd<int > vi2 = splat (-1 );
42- simd<float > vf1 = splat (1 .0f );
43- simd<float > vf2 = splat (-1 .0f );
44-
45- simd<int > v_abs = abs (vi2);
46- simd<int > v_min = min (vi1, vi2);
47- simd<int > v_max = max (vi1, vi2);
48- simd<float > v_fma = fma (vf1, vf2, vf1);
49- simd<float > v_ceil = ceil (splat (1 .2f ));
50- simd<float > v_floor = floor (splat (1 .8f ));
51- simd<float > v_roundeven = roundeven (splat (2 .5f ));
52- simd<float > v_round = round (splat (2 .5f ));
53- simd<float > v_trunc = trunc (splat (-2 .9f ));
54- simd<float > v_nearbyint = nearbyint (splat (3 .4f ));
55- simd<float > v_rint = rint (splat (3 .6f ));
56- simd<float > v_canonicalize = canonicalize (splat (1 .0f ));
57- simd<float > v_copysign = copysign (vf1, vf2);
41+ cpp:: simd<int > vi1 = cpp:: splat (1 );
42+ cpp:: simd<int > vi2 = cpp:: splat (-1 );
43+ cpp:: simd<float > vf1 = cpp:: splat (1 .0f );
44+ cpp:: simd<float > vf2 = cpp:: splat (-1 .0f );
45+
46+ cpp:: simd<int > v_abs = cpp:: abs (vi2);
47+ cpp:: simd<int > v_min = cpp:: min (vi1, vi2);
48+ cpp:: simd<int > v_max = cpp:: max (vi1, vi2);
49+ cpp:: simd<float > v_fma = cpp:: fma (vf1, vf2, vf1);
50+ cpp:: simd<float > v_ceil = cpp:: ceil (cpp:: splat (1 .2f ));
51+ cpp:: simd<float > v_floor = cpp:: floor (cpp:: splat (1 .8f ));
52+ cpp:: simd<float > v_roundeven = cpp:: roundeven (cpp:: splat (2 .5f ));
53+ cpp:: simd<float > v_round = cpp:: round (cpp:: splat (2 .5f ));
54+ cpp:: simd<float > v_trunc = cpp:: trunc (cpp:: splat (-2 .9f ));
55+ cpp:: simd<float > v_nearbyint = cpp:: nearbyint (cpp:: splat (3 .4f ));
56+ cpp:: simd<float > v_rint = cpp:: rint (cpp:: splat (3 .6f ));
57+ cpp:: simd<float > v_canonicalize = cpp:: canonicalize (cpp:: splat (1 .0f ));
58+ cpp:: simd<float > v_copysign = cpp:: copysign (vf1, vf2);
5859
5960 EXPECT_EQ (v_abs[0 ], 1 );
6061 EXPECT_EQ (v_min[0 ], -1 );
@@ -72,21 +73,21 @@ TEST(LlvmLibcSIMDTest, ElementwiseOperations) {
7273}
7374
7475TEST (LlvmLibcSIMDTest, ReductionOperations) {
75- simd<int > v = splat (1 );
76+ cpp:: simd<int > v = cpp:: splat (1 );
7677
77- int sum = reduce (v);
78- int prod = reduce (v, multiplies<>{});
78+ int sum = cpp:: reduce (v);
79+ int prod = cpp:: reduce (v, cpp:: multiplies<>{});
7980
80- EXPECT_EQ (sum, static_cast <int >(simd_size_v<decltype (v)>));
81+ EXPECT_EQ (sum, static_cast <int >(cpp:: simd_size_v<decltype (v)>));
8182 EXPECT_EQ (prod, 1 );
8283}
8384
8485TEST (LlvmLibcSIMDTest, MaskOperations) {
85- simd<bool , 8 > mask{true , false , true , false , false , false , false , false };
86+ cpp:: simd<bool , 8 > mask{true , false , true , false , false , false , false , false };
8687
87- EXPECT_TRUE (any_of (mask));
88- EXPECT_FALSE (all_of (mask));
89- EXPECT_TRUE (some_of (mask));
90- EXPECT_EQ (find_first_set (mask), 0 );
91- EXPECT_EQ (find_last_set (mask), 2 );
88+ EXPECT_TRUE (cpp:: any_of (mask));
89+ EXPECT_FALSE (cpp:: all_of (mask));
90+ EXPECT_TRUE (cpp:: some_of (mask));
91+ EXPECT_EQ (cpp:: find_first_set (mask), 0 );
92+ EXPECT_EQ (cpp:: find_last_set (mask), 2 );
9293}
0 commit comments