aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Modules/pr91418.cppm
blob: b507df162643bae17b9092ad7a712d613269aefb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -x c++-header %t/foo.h \
// RUN:     -emit-pch -o %t/foo.pch
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/use.cpp -include-pch \
// RUN:     %t/foo.pch -emit-llvm -o - | FileCheck %t/use.cpp

//--- foo.h
#ifndef FOO_H
#define FOO_H
typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));

static __inline__ __m128 __attribute__((__always_inline__, __min_vector_width__(128)))
_mm_setr_ps(float __z, float __y, float __x, float __w)
{
  return __extension__ (__m128){ __z, __y, __x, __w };
}

typedef __m128 VR;

inline VR MakeVR( float X, float Y, float Z, float W )
{
 return _mm_setr_ps( X, Y, Z, W );
}

extern "C" float sqrtf(float);

namespace VectorSinConstantsSSE
{
  float a = (16 * sqrtf(0.225f));
  VR A = MakeVR(a, a, a, a);
  static const float b = (16 * sqrtf(0.225f));
  static const VR B = MakeVR(b, b, b, b);
}

#endif // FOO_H

//--- use.cpp
#include "foo.h"
float use() {
    return VectorSinConstantsSSE::A[0] + VectorSinConstantsSSE::A[1] +
           VectorSinConstantsSSE::A[2] + VectorSinConstantsSSE::A[3] +
           VectorSinConstantsSSE::B[0] + VectorSinConstantsSSE::B[1] +
           VectorSinConstantsSSE::B[2] + VectorSinConstantsSSE::B[3];
}

// CHECK: define{{.*}}@__cxx_global_var_init(
// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSE1aE

// CHECK: define{{.*}}@__cxx_global_var_init.1(
// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSE1AE

// CHECK: define{{.*}}@__cxx_global_var_init.2(
// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSEL1BE

// CHECK: define{{.*}}@__cxx_global_var_init.3(
// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSEL1bE

// CHECK: @_GLOBAL__sub_I_use.cpp
// CHECK: call{{.*}}@__cxx_global_var_init(
// CHECK: call{{.*}}@__cxx_global_var_init.1(
// CHECK: call{{.*}}@__cxx_global_var_init.3(
// CHECK: call{{.*}}@__cxx_global_var_init.2(