Check out the SIMD instructions (SSE,MMX,Altivec,etc) for your CPU. I know that Altivec has specific bounds checking operations and also has bitwise comparisons to make a mask for the vector. For example, I've used the latter to eliminate branching in video keying functions with good results.
cgc
Quoting Thomas Grill t.grill@gmx.net:
Hi Luigi, i'm not sure if it's really necessary to avoid branching in any case. All of the new CPUs have a branch prediction that keeps the instruction queues filled, so it's maybe only about hinting the CPU in the right direction. There are general rules how branching is predicted (like jumps forward are not suspected to happen, while jumps backwards are) - have a look at the CPU manuals!
best greetings, Thomas
----- Original Message ----- From: "Luigi Castelli" superbigio@yahoo.com To: pd-dev@iem.at Sent: Monday, October 13, 2003 4:40 AM Subject: [PD-dev] Non-branching clipping algo...
Hi,
I am trying to find a way to clip incoming values to a range from 0.0 to 1.0 without using branching.
I found a bunch of algorithms on musicdsp.org to achieve clipping without branching but none were satisfactory.
What I am really aiming for is to find a way to modify the tabfudge technique used in d_osc.c to achieve clipping instead of wrapping. Is that possible ?
Thanks for any help or suggestion.
- Luigi
===== Luigi Castelli
superbigio@yahoo.com
Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev