brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · ed575e1 Raw
55 lines · cpp
1// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s2 3template<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) noexcept24        {25            for (auto i = 0u; i != rank; ++i) data[i] = x;26        }27        my_vector_type& operator+=(const my_vector_type& x) noexcept28        {29            data += x.data;30            return *this;31        }32    };33 34template<typename T, unsigned int n>35    inline36    my_vector_type<T, n> operator+(37        const my_vector_type<T, n>& x, const my_vector_type<T, n>& y) noexcept38    {39        return my_vector_type<T, n>{x} += y;40    }41 42using char1 = my_vector_type<char, 1>;43 44void mane() {45 46    char1 f1{1};47    char1 f2{1};48 49// CHECK: [[CALL:%.*]] = call i1650// CHECK: [[TRUNC:%.*]] = trunc i16 [[CALL]] to i851// CHECK: store i8 [[TRUNC]]52 53    char1 f3 = f1 + f2;54}55