From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Thomas To: gcc@gcc.gnu.org Subject: AltiVec in gcc-current: questions. Date: Sat, 10 Aug 2002 01:00:00 -0000 Message-id: <5.1.0.14.2.20020810000144.04175008@3am-software.com> X-SW-Source: 2002-08/msg00558.html 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