This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

AltiVec in gcc-current: questions.


I've implemented the IP checksum in AltiVec.  I have it working just
fine with __asm()'s on gcc 2.95.3.   Now I'm using gcc-current and
trying to use -mabi=altivec and the vec_* calls.  I've converted the
asm's for everything to the proper vec_* except for my use of the
vec_vmrghh (and vec_vmrglh) builtins.  I also wish I could get 16
byte aligned automatic variables but that's a different issue.

I'm using them in asm()'s to split upper or lower 4 of the 8 HI's
into 4 SIs by using a zeroed vector register and doing to

        vmrghh dst,zero,src

where dst is a vector unsigned int and src is a vector unsigned short.
(dst could equally be a vector signed int).  But the builtins say
that vmrg[hl]h only result in V8HI.  This wouldn't be so bad if I
could cast the vectors but the compiler seems to disallow that.

So for now, I'm using an __asm() for my two vmrg[lh]h calls.

Here's a more detailed view of what I'm doing:

After I loaded the data and added it all together, my cksum routine
has two V4SI vectors with corresponding hi and lo sums.  Now I can
treat the lo sum as a V8HI vector and split its content into two
V4SI vectors which I can together.

        vector unsigned int data, zero, sumlo, sumhi;

        zero ^= zero;
        sumlo = zero;
        sumhi = zero;

        while (dp < ep) {
                vec_ld(data, 0, dp);
                sumhi += vec_addc(sumlo, data);
                sumlo += data;
                dp += 4;
        }

        sumhi += vmrghh(zero, sumlo) + vmrglh(zero, sumlo);
        sumlo = vmrghw(zero, sumhi) + vmrglw(zero, sumhi);
        /* now I have V2DI (effectively) */

        vec_st(sumlo, 0, tmp);

        sum = tmp[1] + tmp[3];  /* BE of course */
        REDUCE(sum);
        ...

Comments?

--
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt/
Cupertino, CA             Disclaimer: I avow all knowledge of this message


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]