Cryptic code == Optimized code ? YES : NO ;
Jon C. R. Bennett
jb7m+ at andrew.cmu.edu
Fri Sep 28 04:23:01 AEST 1990
dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
> The real question is whether the swap macro using exclusive OR is
> faster than a swap() function.
since we are concerned with what a good compiler will do with the code (if
you are dealing with a bad compiler you have bigger problems) will
produce, the swap function is almost certin to be faster, since it is so
small that it will be inlined, and then since it is a null operation,
eliminated, making the swap faster.
jon
an interesting aside, does anyone who is very familiar with GCC machine
description files think that they could write a peephole optimization that
spots a^=b^=a^=b and converts it to a swap insted.
More information about the Comp.lang.c
mailing list