1 // PR tree-optimization/56381
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -w" }
6 class intrusive_ptr {};
7 class BasicReferenceCounted
11 class ReferenceCountingPointer : intrusive_ptr <T>
14 typedef BasicReferenceCounted ReferenceCountedInConditions;
16 template <typename T, typename>
17 struct PreciseFloatType
21 template <typename T, int N>
24 typedef T __attribute__ ((vector_size (N * sizeof (T)))) type;
26 template <typename T, int N>
27 using ExtVec = typename ExtVecTraits <T, N>::type;
28 template <typename T> using Vec4 = ExtVec <T, 4>;
29 template <typename Vec>
30 Vec cross3 (Vec x, Vec y)
32 Vec x1200 = (Vec) { x[2], x[0] };
33 Vec y2010 { y[2], y[0], y[1], y[0] };
34 Vec x2010 = (Vec) { x[2], x[0], x[1], x[0] };
35 Vec y1200 = (Vec) { y[1], y[0] };
36 return x1200 * y2010 - x2010 * y1200;
50 typedef Vec4 <T> MathVector;
51 Basic3DVector (MathVector iv) : v { (iv[0]), (iv[1]), (iv[2]), (iv[3]) } {}
56 return (my_mag) ? (*this) * (T () / (my_mag)) : *this;
59 cross (Basic3DVector lh) { return cross3 (v, lh.v); }
63 Basic3DVector <T> operator * (Basic3DVector <T>, T);
64 template <class T, class, class>
67 typedef Basic3DVector <T> BasicVectorType;
69 PV3DBase (Basic3DVector <U> v) : theVector (v) {}
70 BasicVectorType basicVector () { return theVector; }
73 BasicVectorType theVector;
76 template <class T, class FrameTag>
77 struct Vector3DBase:public PV3DBase <T, VectorTag, FrameTag>
79 typedef PV3DBase <T, VectorTag, FrameTag> BaseClass;
81 Vector3DBase (Basic3DVector <U> v) : BaseClass (v) {}
82 Vector3DBase unit () { return (this->basicVector ().unit ()); }
84 Vector3DBase <typename PreciseFloatType <T, U>::Type, FrameTag> cross (Vector3DBase <U, FrameTag> v)
86 return (this->theVector.cross (v.basicVector ()));
89 template <class T, class FrameTag>
90 class Point3DBase : public PV3DBase <T, PointTag, FrameTag>
93 template <typename T, typename U, class Frame>
94 Vector3DBase <typename PreciseFloatType <T, U>::Type, Frame> operator - (Point3DBase <T, Frame>, Point3DBase <U, Frame>);
99 typedef Vector3DBase <T, GlobalTag> GlobalVector;
100 TkRotation (GlobalVector aX, GlobalVector aY)
102 GlobalVector uX = aX.unit ();
103 GlobalVector uY = aY.unit ();
104 GlobalVector uZ (uX.cross (uY));
105 rot.axis[2] = uZ.basicVector ().v;
107 Basic3DVector <T> z ();
111 struct GloballyPositioned
113 typedef Point3DBase <T, GlobalTag> PositionType;
114 typedef TkRotation <T> RotationType;
115 typedef Point3DBase <T, GlobalTag> GlobalPoint;
116 typedef Vector3DBase <T, GlobalTag> GlobalVector;
117 T iniPhi () { return 999.9978; }
118 GloballyPositioned (PositionType pos, RotationType rot) : thePos (pos), theRot (rot) { resetCache (); }
119 PositionType position () const;
120 RotationType rotation () const;
125 if ((thePos.x () == 0.) && (thePos.y () == 0.))
133 using TangentPlane = Plane;
134 struct Surface : public GloballyPositioned <float>, ReferenceCountedInConditions
136 typedef GloballyPositioned <float> Base;
137 Surface (PositionType pos, RotationType rot):
140 struct Plane : Surface
142 template <typename ... Args>
143 Plane (Args ... args):
144 Surface ((args) ...) {}
146 class Cylinder : Surface
148 void tangentPlane (const GlobalPoint &) const;
151 Cylinder::tangentPlane (const GlobalPoint & aPoint) const
153 GlobalVector yPlane (rotation ().z ());
154 GlobalVector xPlane (yPlane.cross (aPoint - position ()));
155 new TangentPlane (aPoint, RotationType (xPlane, yPlane));