Path: utzoo!attcan!uunet!bu.edu!rpi!zaphod.mps.ohio-state.edu!samsung!umich!mailrus!iuvax!rutgers!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!jb7m+ From: jb7m+@andrew.cmu.edu (Jon C. R. Bennett) Newsgroups: comp.lang.c Subject: Re: Cryptic code == Optimized code ? YES : NO ; Message-ID: Date: 27 Sep 90 18:23:01 GMT References: <861@gtenmc.UUCP>, <168@thor.UUCP> , <2514@cirrusl.UUCP> Organization: Carnegie Institute of Technology, Carnegie Mellon, Pittsburgh, PA Lines: 16 In-Reply-To: <2514@cirrusl.UUCP> dhesi%cirrusl@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.