aliasing revisited

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all -

I know that there are at least a billion and one messages on the list
about aliasing, but I can't remember seeing one specifically like
this.  The gist is that I want to compute a bunch of floating point
stuff in SSE units and store the output in an array.  Then I want to
reinterpret the items as integers (booleans actually).  The code
snippet ls like so:

...
    strat.generateSamples(ctx.rng, samples);

    simd4f *r = samples.getDim(0);
    simd4f *rend = r + simdSize;
    simd4f *c = reinterpret_cast<simd4f*>(m_leftRep);

    simd4f sp(lpow), asp(tpow);

    for(; r != rend; ++r, ++c) { *c = *r * asp < sp; }

    for(size_t i = 0; i < m_numReps; i += 4) {
        m_rep[i+0] = m_leftRep[i+0] ? ll[incLeft*(i+0)] : rl[incRight*(i+0)];
        m_rep[i+1] = m_leftRep[i+1] ? ll[incLeft*(i+1)] : rl[incRight*(i+1)];
        m_rep[i+2] = m_leftRep[i+2] ? ll[incLeft*(i+2)] : rl[incRight*(i+2)];
        m_rep[i+3] = m_leftRep[i+3] ? ll[incLeft*(i+3)] : rl[incRight*(i+3)];
    }
...

simd4f is a wrapper on __m128, and "m_leftRep" is an array of
uint32_t.  I realize that I could just create a simd4f array for "c",
perform the first loop, and then put a union in the second loop.  This
would require at least one extra write per uint32_t though.  Is there
any way of specifying that "c" aliases "m_leftRep"?  Or am I stuck
with the union?

Thanks,
  Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux