[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] code question?
On Thu, 11 Aug 2005, Keir Fraser wrote: Forming compound predicates for bitwise operators can be faster than using the logical operators because they are non 'short circuiting'. This means you end up with fewer branches in the generated code and end up with nice straight-line code that should execute fast. Is it worth it to perform these optimizations? For example the code to get time information in xen/386 linux: do { shadow_tv_version = s->wc_version; rmb(); shadow_tv.tv_sec = s->wc_sec; shadow_tv.tv_nsec = s->wc_nsec; rmb(); } while ((s->wc_version & 1) | (shadow_tv_version ^ s->wc_version));Granted most experienced programmers will recognize that the xor is used to test for inequality and the bitwise-or is used as a logical-or. But how often does this piece of code even run? Seems like a case of trading readability for speed when optimization isn't even important. -- Keir Tim Newsham http://www.lava.net/~newsham/ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |