Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fastest way to change sign of the odd elements of vSInt16



On 25 Nov 2005, at 07:40, Rustam Muginov wrote:

Hello, all.
In my calculation, i need to change sign of the odd elements of sInt16 vector, i.e. take the original
vSInt16 v // containing s0, s1, s2, s3, s4, s5, s6, s7,
and convert in into
vSInt16 v_inverted // containing s0, -s1, s2, -s3, s4, -s5, s6, -s7


I am using such vector to perform msum later.

Currenty i am using three instruction approach, using two additional pre-created vector.
It is something like this:


vD0_signinverted = vec_nor( vD0_rotated, vD0_rotated ); // ~d0.im, ~d0.re, ~d1.im, ~d1.re, ~d2.im, ~d2.re, ~d3.im, ~d3.re
vD0_signinverted = vec_add( vD0_signinverted, v_One16 ); // -d0.im, -d0.re, -d1.im, -d1.re, -d2.im, -d2.re, -d3.im, -d3.re
vD0_signinverted = vec_sel( vD0_rotated, vD0_signinverted, maskIm ); // d0.im, -d0.re, d1.im, -d1.re, d2.im, -d2.re, d3.im, - d3.re

where v_One16 is vSInt16 containing 1 in each element, and maskIm is vSInt16 containging ( 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF );


First step is to get one's complement
Second is to add one (thus changing sign to all elements)
Third is select even element from original vector and odd from inverted


Could this be done using less instructions or less addidional registers?
Thank you.



You can just subtract from zero to get the sign inverted vector - you would save one instruction and could lose the v_One16 vector but you'd need a zero vector (these usually come for free though).


Paul

_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden
References: 
 >Fastest way to change sign of the odd elements of vSInt16 (From: Rustam Muginov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.