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: float to int (kinda OT)



> > From: Holger Bettag <email@hidden>
> > Date: October 22, 2004 11:05:05 AM EDT
> > To: email@hidden
> > Subject: Re: float to int (kinda OT)

> > How about using the sign bits directly:
> >
> >   if ((a | b | c) <0) return 1; else return 0;
> >
> > or totally without branch in this particular example:
> >
> >   return ((unsigned)(a | b | c)) >> ((sizeof(int) << 3) - 1);

Nice...that's definitely faster! Note that both GCC 4 and XLC will produce
the same branch-less code for either case above:

        or r4,r3,r4
        or r4,r4,r5
        srwi r3,r4,31
        blr

--Sanjay




		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 
 _______________________________________________
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



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.