This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use assert()s for optimization?


On Friday 7 November 2003 22:48, Falk Hueffner wrote:
> Ross Smith <r-smith@ihug.co.nz> writes:
> > On Friday 7 November 2003 11:01, Falk Hueffner wrote:
> > > Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
> > > > Is there a way to turn an assert() into optimization hints for
> > > > gcc? Like in
> > > >
> > > > double mysqrt(double x)
> > > > {
> > > >   assert(x >= 0.0);
> > > >   return sqrt(x);
> > > > }
> > >
> > > Interestingly, Toon Moene just asked for the same thing on
> > > gcc-patches :) I don't think it's currently possible. Maybe we
> > > could have
> > > something similar to Microsoft's __assume(), which would then
> > > feed the nonnegative_p etc. functions and the VRP to come. I'm
> > > not sure how to represent it best in the intermediary
> > > representation, though.
> >
> > Doesn't __builtin_expect() already do this?
>
> No. It only means "feel free to waste cycles should x not be true",
> not "feel free to produce undefined behaviour should x not be true".

Perhaps I misundertstood the question -- the OP referred to 
"optimization hints", so I thought that behaviour was what he wanted.

-- 
Ross Smith ......... r-smith@ihug.co.nz ......... Auckland, New Zealand
  "The vast majority of Iraqis want to live in a peaceful, free world.
  And we will find these people and we will bring them to justice."
                                                     -- George W. Bush


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]