|
| 1 | +// RUN: rm -rf %t |
| 2 | +// RUN: mkdir -p %t |
| 3 | +// RUN: split-file %s %t |
| 4 | +// |
| 5 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -x c++-header %t/foo.h \ |
| 6 | +// RUN: -emit-pch -o %t/foo.pch |
| 7 | +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/use.cpp -include-pch \ |
| 8 | +// RUN: %t/foo.pch -emit-llvm -o - | FileCheck %t/use.cpp |
| 9 | + |
| 10 | +//--- foo.h |
| 11 | +#ifndef FOO_H |
| 12 | +#define FOO_H |
| 13 | +typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16))); |
| 14 | + |
| 15 | +static __inline__ __m128 __attribute__((__always_inline__, __min_vector_width__(128))) |
| 16 | +_mm_setr_ps(float __z, float __y, float __x, float __w) |
| 17 | +{ |
| 18 | + return __extension__ (__m128){ __z, __y, __x, __w }; |
| 19 | +} |
| 20 | + |
| 21 | +typedef __m128 VR; |
| 22 | + |
| 23 | +inline VR MakeVR( float X, float Y, float Z, float W ) |
| 24 | +{ |
| 25 | + return _mm_setr_ps( X, Y, Z, W ); |
| 26 | +} |
| 27 | + |
| 28 | +extern "C" float sqrtf(float); |
| 29 | + |
| 30 | +namespace VectorSinConstantsSSE |
| 31 | +{ |
| 32 | + float a = (16 * sqrtf(0.225f)); |
| 33 | + VR A = MakeVR(a, a, a, a); |
| 34 | + static const float b = (16 * sqrtf(0.225f)); |
| 35 | + static const VR B = MakeVR(b, b, b, b); |
| 36 | +} |
| 37 | + |
| 38 | +#endif // FOO_H |
| 39 | + |
| 40 | +//--- use.cpp |
| 41 | +#include "foo.h" |
| 42 | +float use() { |
| 43 | + return VectorSinConstantsSSE::A[0] + VectorSinConstantsSSE::A[1] + |
| 44 | + VectorSinConstantsSSE::A[2] + VectorSinConstantsSSE::A[3] + |
| 45 | + VectorSinConstantsSSE::B[0] + VectorSinConstantsSSE::B[1] + |
| 46 | + VectorSinConstantsSSE::B[2] + VectorSinConstantsSSE::B[3]; |
| 47 | +} |
| 48 | + |
| 49 | +// CHECK: define{{.*}}@__cxx_global_var_init( |
| 50 | +// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSE1aE |
| 51 | + |
| 52 | +// CHECK: define{{.*}}@__cxx_global_var_init.1( |
| 53 | +// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSE1AE |
| 54 | + |
| 55 | +// CHECK: define{{.*}}@__cxx_global_var_init.2( |
| 56 | +// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSEL1BE |
| 57 | + |
| 58 | +// CHECK: define{{.*}}@__cxx_global_var_init.3( |
| 59 | +// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSEL1bE |
| 60 | + |
| 61 | +// CHECK: @_GLOBAL__sub_I_use.cpp |
| 62 | +// CHECK: call{{.*}}@__cxx_global_var_init( |
| 63 | +// CHECK: call{{.*}}@__cxx_global_var_init.1( |
| 64 | +// CHECK: call{{.*}}@__cxx_global_var_init.3( |
| 65 | +// CHECK: call{{.*}}@__cxx_global_var_init.2( |
0 commit comments