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/