annotate gcc/testsuite/g++.dg/opt/pr44919.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } }
kono
parents:
diff changeset
2 // { dg-options "-O3 -fselective-scheduling2" }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 namespace std {
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 typedef long unsigned int size_t;
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 template<typename _Tp> class new_allocator { public: typedef size_t size_type; typedef _Tp* pointer; };
kono
parents:
diff changeset
9 template<typename _Tp> class allocator: public new_allocator<_Tp> { public: typedef size_t size_type; template<typename _Tp1> struct rebind { typedef allocator<_Tp1> other; }; };
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 class back_insert_iterator { };
kono
parents:
diff changeset
12 template<typename _Container> back_insert_iterator back_inserter(_Container& __x) { };
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 class vector { };
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 struct _List_node_base { };
kono
parents:
diff changeset
17 struct _List_node : public _List_node_base { };
kono
parents:
diff changeset
18 template<typename _Tp> struct _List_iterator { typedef _List_iterator<_Tp> _Self; typedef _Tp& reference; explicit _List_iterator(_List_node_base* __x) : _M_node(__x) { } reference operator*() const { } _Self& operator++() { } bool operator!=(const _Self& __x) const { return _M_node != __x._M_node; } _List_node_base* _M_node; };
kono
parents:
diff changeset
19 template<typename _Tp, typename _Alloc> class _List_base { protected: typedef typename _Alloc::template rebind<_List_node >::other _Node_alloc_type; struct _List_impl : public _Node_alloc_type { _List_node_base _M_node; }; _List_impl _M_impl; };
kono
parents:
diff changeset
20 template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class list : protected _List_base<_Tp, _Alloc> { public: typedef _Tp value_type; typedef _List_iterator<_Tp> iterator; iterator begin() { } iterator end() { return iterator(&this->_M_impl._M_node); } };
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 namespace tr1 { template<typename _Tp, size_t _Nm> struct array { typedef _Tp value_type; typedef const value_type& const_reference; typedef const value_type* const_iterator; typedef size_t size_type; value_type _M_instance[_Nm ? _Nm : 1]; const_iterator begin() const { return const_iterator(&_M_instance[0]); } const_reference operator[](size_type __n) const { return _M_instance[__n]; } }; }
kono
parents:
diff changeset
23 }
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 namespace X {
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 class Object { };
kono
parents:
diff changeset
28 struct Has_qrt { };
kono
parents:
diff changeset
29 template <typename F> struct qrt_or_not { typedef const typename F::result_type & type; };
kono
parents:
diff changeset
30 template <typename Functor, typename P1 = void> struct Qualified_result_of : qrt_or_not<Functor> { };
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 using std::tr1::array;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 template <class R_> class Point_2 : public R_::Kernel_base::Point_2 {
kono
parents:
diff changeset
35 public:
kono
parents:
diff changeset
36 typedef typename R_::Kernel_base::Point_2 RPoint_2;
kono
parents:
diff changeset
37 typedef RPoint_2 Rep;
kono
parents:
diff changeset
38 const Rep& rep() const { }
kono
parents:
diff changeset
39 };
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 template <class R_> class Vector_2 : public R_::Kernel_base::Vector_2 {
kono
parents:
diff changeset
42 public:
kono
parents:
diff changeset
43 typedef typename R_::Kernel_base::Vector_2 RVector_2;
kono
parents:
diff changeset
44 typedef RVector_2 Rep;
kono
parents:
diff changeset
45 const Rep& rep() const { return *this; }
kono
parents:
diff changeset
46 typedef R_ R;
kono
parents:
diff changeset
47 typename Qualified_result_of<typename R::Compute_x_2,Vector_2>::type x() const { return R().compute_x_2_object()(*this); }
kono
parents:
diff changeset
48 typename Qualified_result_of<typename R::Compute_y_2,Vector_2>::type y() const { return R().compute_y_2_object()(*this); }
kono
parents:
diff changeset
49 typename Qualified_result_of<typename R::Compute_y_2,Vector_2>::type cartesian(int i) const { return (i==0) ? x() : y(); }
kono
parents:
diff changeset
50 typename Qualified_result_of<typename R::Compute_hx_2,Vector_2>::type hx() const { return R().compute_hx_2_object()(*this); }
kono
parents:
diff changeset
51 typename Qualified_result_of<typename R::Compute_hy_2,Vector_2>::type hy() const { return R().compute_hy_2_object()(*this); }
kono
parents:
diff changeset
52 typename Qualified_result_of<typename R::Compute_hw_2,Vector_2>::type hw() const { return R().compute_hw_2_object()(*this); }
kono
parents:
diff changeset
53 typename Qualified_result_of<typename R::Compute_hx_2,Vector_2>::type homogeneous(int i) const { return (i==0) ? hx() : (i==1)? hy() : hw(); }
kono
parents:
diff changeset
54 };
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 template <class R_> class Segment_2 : public R_::Kernel_base::Segment_2 { };
kono
parents:
diff changeset
57 template <class R_> class Iso_rectangle_2 : public R_::Kernel_base::Iso_rectangle_2 { };
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 template <typename T, int i > const T& constant() { static const T t(i); return t; }
kono
parents:
diff changeset
60 template <class T, class Alloc = std::allocator<T > > class Handle_for { struct RefCounted { T t; }; typedef typename Alloc::template rebind<RefCounted>::other Allocator; typedef typename Allocator::pointer pointer; pointer ptr_; public: typedef T element_type; const T * Ptr() const { return &(ptr_->t); } };
kono
parents:
diff changeset
61 template <class T, class Allocator> const T& get(const Handle_for<T, Allocator> &h) { return *(h.Ptr()); }
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 template <class R_> class PointC2 {
kono
parents:
diff changeset
64 public:
kono
parents:
diff changeset
65 typedef typename R_::Vector_2 Vector_2; Vector_2 base;
kono
parents:
diff changeset
66 typedef typename Vector_2::Cartesian_const_iterator Cartesian_const_iterator; Cartesian_const_iterator cartesian_begin() const { return base.cartesian_begin(); }
kono
parents:
diff changeset
67 };
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 template <class R_> class VectorC2 {
kono
parents:
diff changeset
70 public:
kono
parents:
diff changeset
71 typedef typename R_::FT FT;
kono
parents:
diff changeset
72 typedef array<FT, 2> Rep;
kono
parents:
diff changeset
73 typedef typename R_::template Handle<Rep>::type Base;
kono
parents:
diff changeset
74 Base base;
kono
parents:
diff changeset
75 typedef typename Rep::const_iterator Cartesian_const_iterator;
kono
parents:
diff changeset
76 const FT & x() const { return X::get(base)[0]; }
kono
parents:
diff changeset
77 const FT & y() const { return X::get(base)[1]; }
kono
parents:
diff changeset
78 const FT & hx() const { return x(); }
kono
parents:
diff changeset
79 const FT & hy() const { return y(); }
kono
parents:
diff changeset
80 const FT & hw() const { return constant<FT, 1>(); }
kono
parents:
diff changeset
81 Cartesian_const_iterator cartesian_begin() const { return X::get(base).begin(); }
kono
parents:
diff changeset
82 };
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 template <class R_> class SegmentC2 { };
kono
parents:
diff changeset
85 template <class R_> class Iso_rectangleC2 { };
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 namespace internal {
kono
parents:
diff changeset
88 template <class K> class Segment_2_Iso_rectangle_2_pair {
kono
parents:
diff changeset
89 public:
kono
parents:
diff changeset
90 enum Intersection_results { NO_INTERSECTION };
kono
parents:
diff changeset
91 Segment_2_Iso_rectangle_2_pair(typename K::Segment_2 const *seg, typename K::Iso_rectangle_2 const *rect) ;
kono
parents:
diff changeset
92 Intersection_results intersection_type() const;
kono
parents:
diff changeset
93 mutable Intersection_results _result;
kono
parents:
diff changeset
94 typename K::Point_2 _ref_point;
kono
parents:
diff changeset
95 typename K::Vector_2 _dir;
kono
parents:
diff changeset
96 typename K::Point_2 _isomin;
kono
parents:
diff changeset
97 typename K::Point_2 _isomax;
kono
parents:
diff changeset
98 mutable typename K::FT _min, _max;
kono
parents:
diff changeset
99 };
kono
parents:
diff changeset
100 template <class K> Object intersection( const typename K::Segment_2 &seg, const typename K::Iso_rectangle_2 &iso, const K&) {
kono
parents:
diff changeset
101 typedef Segment_2_Iso_rectangle_2_pair<K> is_t; is_t ispair(&seg, &iso); switch (ispair.intersection_type()) { }
kono
parents:
diff changeset
102 }
kono
parents:
diff changeset
103 template <class K> typename Segment_2_Iso_rectangle_2_pair<K>::Intersection_results Segment_2_Iso_rectangle_2_pair<K>::intersection_type() const {
kono
parents:
diff changeset
104 typedef typename K::RT RT;
kono
parents:
diff changeset
105 typedef typename K::FT FT;
kono
parents:
diff changeset
106 typename K::Construct_cartesian_const_iterator_2 construct_cccit;
kono
parents:
diff changeset
107 typename K::Cartesian_const_iterator_2 ref_point_it = construct_cccit(_ref_point);
kono
parents:
diff changeset
108 typename K::Cartesian_const_iterator_2 end = construct_cccit(_ref_point, 0);
kono
parents:
diff changeset
109 typename K::Cartesian_const_iterator_2 isomin_it = construct_cccit(_isomin);
kono
parents:
diff changeset
110 typename K::Cartesian_const_iterator_2 isomax_it = construct_cccit(_isomax);
kono
parents:
diff changeset
111 for (unsigned int i=0; ref_point_it != end; ++i, ++ref_point_it, ++isomin_it, ++isomax_it) {
kono
parents:
diff changeset
112 if (_dir.homogeneous(i) == RT(0)) {
kono
parents:
diff changeset
113 if ( *(ref_point_it) <*(isomin_it) ) {
kono
parents:
diff changeset
114 _result = NO_INTERSECTION;
kono
parents:
diff changeset
115 }
kono
parents:
diff changeset
116 if ( *(ref_point_it) > *(isomax_it)) {
kono
parents:
diff changeset
117 _result = NO_INTERSECTION;
kono
parents:
diff changeset
118 }
kono
parents:
diff changeset
119 } else {
kono
parents:
diff changeset
120 FT newmin, newmax;
kono
parents:
diff changeset
121 if (_dir.homogeneous(i) > RT(0)) {
kono
parents:
diff changeset
122 newmin = ( *(isomin_it) - (*ref_point_it)) / _dir.cartesian(i);
kono
parents:
diff changeset
123 newmax = ( *(isomax_it) - (*ref_point_it)) / _dir.cartesian(i);
kono
parents:
diff changeset
124 } else {
kono
parents:
diff changeset
125 newmin = ( (*isomax_it) - (*ref_point_it)) / _dir.cartesian(i);
kono
parents:
diff changeset
126 newmax = ( (*isomin_it) - (*ref_point_it)) / _dir.cartesian(i);
kono
parents:
diff changeset
127 }
kono
parents:
diff changeset
128 if (newmin > _min) _min = newmin;
kono
parents:
diff changeset
129 if (newmax <_max) _max = newmax;
kono
parents:
diff changeset
130 if (_max <_min) { return _result; }
kono
parents:
diff changeset
131 }
kono
parents:
diff changeset
132 }
kono
parents:
diff changeset
133 }
kono
parents:
diff changeset
134 }
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 template <class K> Object intersection(const Segment_2<K> &seg, const Iso_rectangle_2<K> &iso) { typedef typename K::Intersect_2 Intersect; return Intersect()(seg, iso); }
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 namespace CommonKernelFunctors {
kono
parents:
diff changeset
139 template <typename K> class Construct_cartesian_const_iterator_2 {
kono
parents:
diff changeset
140 typedef typename K::Point_2 Point_2;
kono
parents:
diff changeset
141 typedef typename K::Cartesian_const_iterator_2 Cartesian_const_iterator_2;
kono
parents:
diff changeset
142 public:
kono
parents:
diff changeset
143 typedef Cartesian_const_iterator_2 result_type;
kono
parents:
diff changeset
144 Cartesian_const_iterator_2 operator()( const Point_2& p) const { return p.rep().cartesian_begin(); }
kono
parents:
diff changeset
145 Cartesian_const_iterator_2 operator()( const Point_2& p, int) const { }
kono
parents:
diff changeset
146 };
kono
parents:
diff changeset
147 template <typename K> class Intersect_2 {
kono
parents:
diff changeset
148 typedef typename K::Object_2 Object_2;
kono
parents:
diff changeset
149 public:
kono
parents:
diff changeset
150 typedef Object_2 result_type;
kono
parents:
diff changeset
151 template <class T1, class T2> Object_2 operator()(const T1& t1, const T2& t2) const { return internal::intersection(t1, t2, K()); }
kono
parents:
diff changeset
152 };
kono
parents:
diff changeset
153 }
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 namespace CartesianKernelFunctors {
kono
parents:
diff changeset
156 using namespace CommonKernelFunctors;
kono
parents:
diff changeset
157 template <typename K> class Compute_x_2 : Has_qrt {
kono
parents:
diff changeset
158 typedef typename K::FT FT;
kono
parents:
diff changeset
159 typedef typename K::Vector_2 Vector_2;
kono
parents:
diff changeset
160 public:
kono
parents:
diff changeset
161 typedef FT result_type;
kono
parents:
diff changeset
162 const result_type & operator()(const Vector_2& v) const { return v.rep().x(); }
kono
parents:
diff changeset
163 };
kono
parents:
diff changeset
164 template <typename K> class Compute_y_2 : Has_qrt {
kono
parents:
diff changeset
165 typedef typename K::FT FT;
kono
parents:
diff changeset
166 typedef typename K::Vector_2 Vector_2;
kono
parents:
diff changeset
167 public:
kono
parents:
diff changeset
168 typedef FT result_type;
kono
parents:
diff changeset
169 const result_type & operator()(const Vector_2& v) const { return v.rep().y(); }
kono
parents:
diff changeset
170 };
kono
parents:
diff changeset
171 template <typename K> class Compute_hx_2 : public Has_qrt {
kono
parents:
diff changeset
172 typedef typename K::FT FT;
kono
parents:
diff changeset
173 typedef typename K::Vector_2 Vector_2;
kono
parents:
diff changeset
174 public:
kono
parents:
diff changeset
175 typedef FT result_type;
kono
parents:
diff changeset
176 const result_type & operator()(const Vector_2& v) const { return v.rep().hx(); }
kono
parents:
diff changeset
177 };
kono
parents:
diff changeset
178 template <typename K> class Compute_hy_2 : public Has_qrt {
kono
parents:
diff changeset
179 typedef typename K::FT FT;
kono
parents:
diff changeset
180 typedef typename K::Vector_2 Vector_2;
kono
parents:
diff changeset
181 public:
kono
parents:
diff changeset
182 typedef FT result_type;
kono
parents:
diff changeset
183 const result_type & operator()(const Vector_2& v) const { return v.rep().hy(); }
kono
parents:
diff changeset
184 };
kono
parents:
diff changeset
185 template <typename K> class Compute_hw_2 : public Has_qrt {
kono
parents:
diff changeset
186 typedef typename K::FT FT;
kono
parents:
diff changeset
187 typedef typename K::Vector_2 Vector_2;
kono
parents:
diff changeset
188 public:
kono
parents:
diff changeset
189 typedef FT result_type;
kono
parents:
diff changeset
190 const result_type & operator()(const Vector_2& v) const { return v.rep().hw(); }
kono
parents:
diff changeset
191 };
kono
parents:
diff changeset
192 }
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 template <typename K_, typename FT_> struct Cartesian_base {
kono
parents:
diff changeset
195 typedef K_ Kernel;
kono
parents:
diff changeset
196 typedef X::Object Object_2;
kono
parents:
diff changeset
197 typedef PointC2<Kernel> Point_2;
kono
parents:
diff changeset
198 typedef VectorC2<Kernel> Vector_2;
kono
parents:
diff changeset
199 typedef SegmentC2<Kernel> Segment_2;
kono
parents:
diff changeset
200 typedef Iso_rectangleC2<Kernel> Iso_rectangle_2;
kono
parents:
diff changeset
201 typedef typename array<FT_, 2>::const_iterator Cartesian_const_iterator_2;
kono
parents:
diff changeset
202 };
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 template <typename K_base, typename Kernel_ > struct Type_equality_wrapper : public K_base {
kono
parents:
diff changeset
205 typedef K_base Kernel_base;
kono
parents:
diff changeset
206 typedef X::Point_2<Kernel_> Point_2;
kono
parents:
diff changeset
207 typedef X::Vector_2<Kernel_> Vector_2;
kono
parents:
diff changeset
208 typedef X::Segment_2<Kernel_> Segment_2;
kono
parents:
diff changeset
209 typedef X::Iso_rectangle_2<Kernel_> Iso_rectangle_2;
kono
parents:
diff changeset
210 };
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 template <typename FT_, typename Kernel_ > struct Cartesian_base_ref_count : public Cartesian_base<Kernel_, FT_ > {
kono
parents:
diff changeset
213 typedef FT_ RT;
kono
parents:
diff changeset
214 typedef FT_ FT;
kono
parents:
diff changeset
215 template <typename T > struct Handle { typedef Handle_for<T> type; };
kono
parents:
diff changeset
216 typedef Kernel_ K;
kono
parents:
diff changeset
217 typedef CartesianKernelFunctors::Compute_x_2<K> Compute_x_2;
kono
parents:
diff changeset
218 Compute_x_2 compute_x_2_object() const { }
kono
parents:
diff changeset
219 typedef CartesianKernelFunctors::Compute_y_2<K> Compute_y_2;
kono
parents:
diff changeset
220 Compute_y_2 compute_y_2_object() const { }
kono
parents:
diff changeset
221 typedef CartesianKernelFunctors::Compute_hx_2<K> Compute_hx_2;
kono
parents:
diff changeset
222 Compute_hx_2 compute_hx_2_object() const { }
kono
parents:
diff changeset
223 typedef CartesianKernelFunctors::Compute_hy_2<K> Compute_hy_2;
kono
parents:
diff changeset
224 Compute_hy_2 compute_hy_2_object() const { }
kono
parents:
diff changeset
225 typedef CartesianKernelFunctors::Compute_hw_2<K> Compute_hw_2;
kono
parents:
diff changeset
226 Compute_hw_2 compute_hw_2_object() const { }
kono
parents:
diff changeset
227 typedef CartesianKernelFunctors::Construct_cartesian_const_iterator_2<K> Construct_cartesian_const_iterator_2;
kono
parents:
diff changeset
228 typedef CartesianKernelFunctors::Intersect_2<K> Intersect_2;
kono
parents:
diff changeset
229 };
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 template <typename FT_ > struct Cartesian : public Type_equality_wrapper<Cartesian_base_ref_count<FT_, Cartesian<FT_> >, Cartesian<FT_> > { };
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 template <class Kernel> class Ipelet_base {
kono
parents:
diff changeset
234 public:
kono
parents:
diff changeset
235 typedef typename X::Point_2<Kernel> Point_2;
kono
parents:
diff changeset
236 typedef typename Kernel::Segment_2 Segment_2;
kono
parents:
diff changeset
237 typedef typename Kernel::Iso_rectangle_2 Iso_rectangle_2;
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 Iso_rectangle_2 read_active_objects () const { }
kono
parents:
diff changeset
240 struct Voronoi_from_tri{ std::list<Segment_2> seg_list; };
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 template <class T,class output_iterator> bool cast_into_seg(const T& obj,const Iso_rectangle_2& bbox,output_iterator out_it) const{ X::intersection(obj,bbox); }
kono
parents:
diff changeset
243 template<class iterator,class output_iterator> void cast_into_seg(const iterator first,const iterator end, const Iso_rectangle_2& bbox, output_iterator out_it) const { for (iterator it=first; it!=end; ++it) cast_into_seg(*it,bbox,out_it); }
kono
parents:
diff changeset
244 void draw_dual_(Voronoi_from_tri& v_recup,const Iso_rectangle_2& bbox) const { std::vector seg_cont; cast_into_seg(v_recup.seg_list.begin(),v_recup.seg_list.end(),bbox,std::back_inserter(seg_cont)); }
kono
parents:
diff changeset
245 void draw_dual_in_ipe(const Iso_rectangle_2& bbox) const { Voronoi_from_tri v_recup; draw_dual_(v_recup,bbox); }
kono
parents:
diff changeset
246 };
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 typedef X::Cartesian<double> Kernel;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 class diagrammeIpelet : public X::Ipelet_base<Kernel> { void protected_run(); };
kono
parents:
diff changeset
251 void diagrammeIpelet::protected_run() { Iso_rectangle_2 bbox = read_active_objects( ); draw_dual_in_ipe(bbox); }
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 }