| 1 |
// { dg-do compile { target i?86-*-* x86_64-*-* } } |
| 2 |
// { dg-options "-std=c++11 -O3 -march=westmere" } |
| 3 |
|
| 4 |
template <int> struct int_ {}; |
| 5 |
template <typename> struct add_const { typedef int type; }; |
| 6 |
template <typename> struct add_reference { typedef int type; }; |
| 7 |
template <typename T> struct next { typedef typename T::next type; }; |
| 8 |
template <typename> struct size_impl; |
| 9 |
template <typename T> struct msvc_eti_base : T {}; |
| 10 |
template <int N> struct long_ { |
| 11 |
static const int value = N; |
| 12 |
typedef long_<N + 1> next; |
| 13 |
}; |
| 14 |
template <typename Sequence> |
| 15 |
struct size : msvc_eti_base<typename size_impl< |
| 16 |
typename Sequence::tag>::template apply<Sequence>> {}; |
| 17 |
template <typename Base> struct v_item : Base { |
| 18 |
typedef typename next<typename Base::size>::type size; |
| 19 |
}; |
| 20 |
template <typename = int> struct vector0 { |
| 21 |
typedef int tag; |
| 22 |
typedef long_<0> size; |
| 23 |
}; |
| 24 |
template <> struct size_impl<int> { |
| 25 |
template <typename Vector> struct apply : Vector::size {}; |
| 26 |
}; |
| 27 |
template <typename> struct vector3 : v_item<v_item<v_item<vector0<>>>> {}; |
| 28 |
template <typename> struct layout { typedef vector3<int> color_space_t; }; |
| 29 |
template <typename> struct kth_element_const_reference_type; |
| 30 |
template <typename> struct iterator_adaptor_get_base; |
| 31 |
template <typename, typename, int> struct homogeneous_color_base; |
| 32 |
template <typename> struct element_const_reference_type; |
| 33 |
template <typename Element, typename Layout> |
| 34 |
struct homogeneous_color_base<Element, Layout, 3> { |
| 35 |
Element _v0, _v1, _v2; |
| 36 |
typename element_const_reference_type<homogeneous_color_base>::type |
| 37 |
at(int_<0>) { |
| 38 |
return _v0; |
| 39 |
} |
| 40 |
typename element_const_reference_type<homogeneous_color_base>::type |
| 41 |
at(int_<1>) { |
| 42 |
return _v1; |
| 43 |
} |
| 44 |
typename element_const_reference_type<homogeneous_color_base>::type |
| 45 |
at(int_<2>) { |
| 46 |
return _v2; |
| 47 |
} |
| 48 |
}; |
| 49 |
template <typename Element, typename Layout, int K1> |
| 50 |
struct kth_element_const_reference_type< |
| 51 |
homogeneous_color_base<Element, Layout, K1>> |
| 52 |
: add_reference<typename add_const<Element>::type> {}; |
| 53 |
template <int K, typename E, typename L, int N> |
| 54 |
typename add_reference<typename add_const<E>::type>::type |
| 55 |
at_c(homogeneous_color_base<E, L, N> p1) { |
| 56 |
return p1.at(int_<K>()); |
| 57 |
} |
| 58 |
template <typename> class memory_based_step_iterator; |
| 59 |
template <typename> class memory_based_2d_locator; |
| 60 |
template <typename> class image_view; |
| 61 |
template <typename, typename> struct pixel; |
| 62 |
struct iterator_type_from_pixel { |
| 63 |
typedef pixel<unsigned char, layout<vector3<int>>> *type; |
| 64 |
}; |
| 65 |
template <typename XIterator> struct type_from_x_iterator { |
| 66 |
typedef image_view< |
| 67 |
memory_based_2d_locator<memory_based_step_iterator<XIterator>>> view_t; |
| 68 |
}; |
| 69 |
template <typename> |
| 70 |
struct element_const_reference_type |
| 71 |
: kth_element_const_reference_type< |
| 72 |
homogeneous_color_base<unsigned, layout<int>, 3>> {}; |
| 73 |
template <typename, typename> |
| 74 |
struct pixel : homogeneous_color_base<unsigned char, layout<int>, |
| 75 |
size<layout<int>::color_space_t>::value> { |
| 76 |
}; |
| 77 |
template <typename Iterator> |
| 78 |
struct iterator_adaptor_get_base<memory_based_step_iterator<Iterator>> { |
| 79 |
typedef Iterator type; |
| 80 |
}; |
| 81 |
template <typename> class memory_based_2d_locator { |
| 82 |
public: |
| 83 |
typedef iterator_adaptor_get_base<memory_based_step_iterator< |
| 84 |
pixel<unsigned, layout<vector3<int>>> *>>::type x_iterator; |
| 85 |
}; |
| 86 |
template <typename> class image_view { |
| 87 |
public: |
| 88 |
typedef memory_based_2d_locator<int>::x_iterator x_iterator; |
| 89 |
x_iterator row_begin___trans_tmp_2; |
| 90 |
x_iterator row_begin(int) { return row_begin___trans_tmp_2; } |
| 91 |
}; |
| 92 |
template <typename, bool, typename = int> class image { |
| 93 |
public: |
| 94 |
typedef type_from_x_iterator<iterator_type_from_pixel::type>::view_t view_t; |
| 95 |
image(int); |
| 96 |
}; |
| 97 |
template <typename Pixel, bool IsPlanar, typename Alloc> |
| 98 |
typename image<Pixel, 0>::view_t view(image<Pixel, IsPlanar, Alloc>); |
| 99 |
template <typename Op> void measure_time(Op p1) { |
| 100 |
for (;;) |
| 101 |
p1(); |
| 102 |
} |
| 103 |
template <typename, typename> struct fill_nongil_t; |
| 104 |
template <typename T, typename P> |
| 105 |
struct fill_nongil_t< |
| 106 |
image_view<memory_based_2d_locator< |
| 107 |
memory_based_step_iterator<pixel<T, layout<vector3<int>>> *>>>, |
| 108 |
P> { |
| 109 |
typedef image_view<memory_based_2d_locator< |
| 110 |
memory_based_step_iterator<pixel<T, layout<vector3<int>>> *>>> View; |
| 111 |
View _v; |
| 112 |
P _p; |
| 113 |
fill_nongil_t(View p1, P) : _v(p1) {} |
| 114 |
void operator()() { |
| 115 |
T *first = (T *)_v.row_begin(0); |
| 116 |
T last; |
| 117 |
while (first != &last) { |
| 118 |
first[0] = at_c<0>(_p); |
| 119 |
first[1] = at_c<1>(_p); |
| 120 |
first[2] = at_c<2>(_p); |
| 121 |
first += 3; |
| 122 |
} |
| 123 |
} |
| 124 |
}; |
| 125 |
template <typename, typename> void test_fill(int) { |
| 126 |
image<int, 0>::view_t __trans_tmp_1; |
| 127 |
image<int, 0> im(0); |
| 128 |
__trans_tmp_1 = view(im); |
| 129 |
measure_time(fill_nongil_t< |
| 130 |
image_view<memory_based_2d_locator<memory_based_step_iterator< |
| 131 |
pixel<unsigned char, layout<vector3<int>>> *>>>, |
| 132 |
pixel<unsigned, int>>(__trans_tmp_1, pixel<unsigned, int>())); |
| 133 |
} |
| 134 |
void performance_testtest_method() { |
| 135 |
test_fill<image_view<int>, pixel<unsigned, int>>(0); |
| 136 |
} |