Boost logo

Boost :

Subject: Re: [boost] [variant] address of a variant type from the address ofitssub-object?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-04-15 04:39:42


On 14 Apr 2016 at 15:14, Chris Glover wrote:

> > That's hard to believe. Copying a pointer should be insignificant compared
> > to the cost of the dispatch. What does the profiler say?
>
> Which compiler? I have found that MSVC is extremely pessimistic with this
> type of situation and generates unnecessary mov instructions for the
> pointer in the struct. You can confirm it, if your case is simple enough,
> by stepping through an inner loop to see if it's reloading that pointer
> over and over again, even though there are no instructions changing the
> pointer in that inner loop.

MSVC doesn't do strict aliasing optimisation. Once upon a time it
could via the /Oa switch, but that facility was removed as people's
code broke.

In your above use case I'd sprinkle some __restrict around. Should
solve the problem.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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