1 | // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s |
2 | |
3 | template<typename T, unsigned int n> struct my_vector_base; |
4 | |
5 | template<typename T> |
6 | struct my_vector_base<T, 1> { |
7 | typedef T Native_vec_ __attribute__((ext_vector_type(1))); |
8 | |
9 | union { |
10 | Native_vec_ data; |
11 | struct { |
12 | T x; |
13 | }; |
14 | }; |
15 | }; |
16 | |
17 | template<typename T, unsigned int rank> |
18 | struct my_vector_type : public my_vector_base<T, rank> { |
19 | using my_vector_base<T, rank>::data; |
20 | using typename my_vector_base<T, rank>::Native_vec_; |
21 | |
22 | template< typename U> |
23 | my_vector_type(U x) noexcept |
24 | { |
25 | for (auto i = 0u; i != rank; ++i) data[i] = x; |
26 | } |
27 | my_vector_type& operator+=(const my_vector_type& x) noexcept |
28 | { |
29 | data += x.data; |
30 | return *this; |
31 | } |
32 | }; |
33 | |
34 | template<typename T, unsigned int n> |
35 | inline |
36 | my_vector_type<T, n> operator+( |
37 | const my_vector_type<T, n>& x, const my_vector_type<T, n>& y) noexcept |
38 | { |
39 | return my_vector_type<T, n>{x} += y; |
40 | } |
41 | |
42 | using char1 = my_vector_type<char, 1>; |
43 | |
44 | int mane() { |
45 | |
46 | char1 f1{1}; |
47 | char1 f2{1}; |
48 | |
49 | // CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16* |
50 | // CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to %{{[^ ]+}} |
51 | |
52 | char1 f3 = f1 + f2; |
53 | } |
54 | |