> -----Original Message----- > From: Jakub Jelinek [mailto:ja...@redhat.com] > Sent: Wednesday, February 12, 2014 12:10 PM > To: Iyer, Balaji V > Cc: 'Jason Merrill'; 'Jeff Law'; 'Aldy Hernandez'; 'gcc-patches@gcc.gnu.org'; > 'r...@redhat.com' > Subject: Re: [PING] [PATCH] _Cilk_for for C and C++ > > On Wed, Feb 12, 2014 at 05:04:38PM +0000, Iyer, Balaji V wrote: > > I looked at the test code you send me (cf3.cc) at -O1 and it is > > removing all the lines you have shown above. Yes, I would imagine -O0 > > to have code that can be redundant or unnecessary. Some of it could > > be the artifact of internal code insertion. But isn't the main job of > > the instruction scheduler to remove all these redundant work? > > Besides, it is just a function call. The compiler at -O2, -O and -O3 > > removes the chunk of code that you mentioned. > > As I said, just change the testcase so that the operator isn't inline, and > suddenly even -O3 will not be able to remove the call.
I am sorry, I do not see any operators being asked to inline explicitly.. class I { public: typedef ptrdiff_t difference_type; I (); ~I (); I (T *); I (const I &); T &operator * (); T *operator -> (); T &operator [] (const difference_type &) const; I &operator = (const I &); I &operator ++ (); I operator ++ (int); I &operator -- (); I operator -- (int); I &operator += (const difference_type &); I &operator -= (const difference_type &); I operator + (const difference_type &) const; I operator - (const difference_type &) const; template <typename S> friend bool operator == (I<S> &, I<S> &); template <typename S> friend bool operator == (const I<S> &, const I<S> &); template <typename S> friend bool operator < (I<S> &, I<S> &); template <typename S> friend bool operator < (const I<S> &, const I<S> &); template <typename S> friend bool operator <= (I<S> &, I<S> &); template <typename S> friend bool operator <= (const I<S> &, const I<S> &); template <typename S> friend bool operator > (I<S> &, I<S> &); template <typename S> friend bool operator > (const I<S> &, const I<S> &); template <typename S> friend bool operator >= (I<S> &, I<S> &); template <typename S> friend bool operator >= (const I<S> &, const I<S> &); template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &); template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &); template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &); private: T *p; }; > > Jakub