From: Geoffrey Irving (irving_at_[hidden])
Date: 2006-09-21 14:41:48
On Thu, Sep 21, 2006 at 02:17:30PM -0400, Michael Fawcett wrote:
> On 9/21/06, Theodore Papadopoulo <Theodore.Papadopoulo_at_[hidden]>
> > On Thu, 2006-09-21 at 08:54 -0400, Michael Fawcett wrote:
> > >
> > > You can get around this using something like this:
> <snip code>
> There was another thread where the participants looked at the generated
> assembly (MSVS 7.1) and found that it was the same as indexing into an
> array. The really interesting thing was that the first time they forgot the
> const keyword and the generated code was sub-optimal. After fixing the
> const-correctness issues the VS 7.1 optimizer was able to produce code
> identical to array indexing.
> No one has posted a detailed analysis of the generated code in more complex
> cases though, but for the simple case it appears that at least VS 7.1 can
> optimize the code just fine.
It's hard to be certain since they didn't actually show the code they were
compiling, but judging by their pseudocode that test is entirely insufficient.
If i is a compile time constant, v[i] is easy to optimize. The hard case is
if i is a arbitrary runtime integer, as mentioned in my previous email.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk