arch-specific template code
Marc Glisse
marc.glisse@inria.fr
Sat Sep 8 14:19:00 GMT 2012
On Sat, 8 Sep 2012, Ulrich Drepper wrote:
> On Sat, Sep 8, 2012 at 6:12 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> PR 54400: horizontal add
>> PR 54408: sqrt
>> PR 54422: unaligned load/store
>> PR 54427: operator< and others in C++
>
> You'll also need various shifting:operations
Thanks for the precision.
> - based on sub-words, measured in bits
So this one is equivalent to doing >> or << on each element independently?
Should already work in C, and 54427 should add it to C++ then :-)
> - a whole vector, byte-wise.
>
> Those are essential for the code like the SFMT implementation. Maybe
> the former you have in PR 54427 but the second is something that
> doesn't exist in C or C++. You can do that via a byte-wise shuffle.
> But in that case the compiler has to recognize the shuffle patterns
> like { 6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,7} and then don't use
> shuffle but instead use the rotate instruction.
I believe every __builtin_shuffle that can be done in a single instruction
is already properly expanded on x86. For this 16 byte vector shuffle, it
uses pshufb. Is there a better instruction? (one that doesn't use a mask
from memory?) Or do you have a clever way to implement those
reverse-cyclic permutations on platforms that didn't have pshufb? (it is
probably not hard to do better than the sse3 code gcc generates for it,
but pre-sse4 PCs are getting less common, so I am not sure it is worth
spending too much effort there)
A harder one I saw you use is some kind of clz/ctz that acts on the whole
vector. I don't think ARM has a similar instruction, and it is not obvious
to me what the best interface would be. It makes sense that not everything
will fit and some target-specific code will have to remain, I just hope
that's not the general case.
--
Marc Glisse
More information about the Libstdc++
mailing list