Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / address-space-cast-coerce.cpp
blob7279b6c7f23a012c017a34b671188b3a94c831ea
1 // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
3 template<typename T, unsigned int n> struct my_vector_base;
5 template<typename T>
6 struct my_vector_base<T, 1> {
7 typedef T Native_vec_ __attribute__((ext_vector_type(1)));
9 union {
10 Native_vec_ data;
11 struct {
12 T x;
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_;
22 template< typename U>
23 my_vector_type(U x) noexcept
25 for (auto i = 0u; i != rank; ++i) data[i] = x;
27 my_vector_type& operator+=(const my_vector_type& x) noexcept
29 data += x.data;
30 return *this;
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
39 return my_vector_type<T, n>{x} += y;
42 using char1 = my_vector_type<char, 1>;
44 int mane() {
46 char1 f1{1};
47 char1 f2{1};
49 // CHECK: [[TMP:%.+]] = alloca i16
50 // CHECK: [[COERCE:%.+]] = addrspacecast ptr addrspace(5) [[TMP]] to ptr
51 // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %{{.+}}, ptr align 2 [[COERCE]], i64 1, i1 false)
53 char1 f3 = f1 + f2;