Boost logo

Boost :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2005-09-14 23:15:58


On 9/15/05, Simon Buchan <simon_at_[hidden]> wrote:
> Marcin Kalicinski wrote:
> > Hi All,
> >
> > Have you considered modifying BOOST_ASSERT to use __assume on MSVC?
> >
> > Briefly speaking __assume(expr) is a hint for optimizer that 'expr'
> > evaluates to nonzero. It can help optimize the code. Standalone use of
> > __assume is not recommended because compiler does not check if the
> > assumption is correct, and if it isn't the program is ill formed. But it
> > fits perfectly in ASSERT macro. This way putting many ASSERTs will not only
> > help to verify the code - it will also help the optimizer. Wow!
> <snip>
> I don't get it, isn't the point of assert that it DOES check them? Or
> did you mean something like GCC's __builtin_expect?
> http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Other-Builtins.html#index-g_t_005f_005fbuiltin_005fexpect-2279

For what I know, the point of assert is that it checks in the debug
build. But has no cost in the release builds. In this case it is even
possible to optimize.

I think this __assume is different from GCC's __builtin_expect because
it still believes it will happens, but the __assume will simply assume
that the case is impossible to happen, just like what an assertion
assumes.

-- 
   Felipe Magno de Almeida
Developer from synergy and Computer Science student from State
University of Campinas(UNICAMP).
Unicamp: http://www.ic.unicamp.br
Synergy: http://www.synergy.com.br
"There is no dark side of the moon really. Matter of fact it's all dark."

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk