Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!ginosko!uunet!ibmpa!ghoti!lmb From: lmb@ghoti.uucp (Larry Breed) Newsgroups: comp.lang.c Subject: Re: swap(x,y) Message-ID: <2155@ibmpa.UUCP> Date: 16 Sep 89 07:59:09 GMT References: <8350@boring.cwi.nl> <10897@smoke.BRL.MIL> <1547@l.cc.purdue.edu> Sender: news@ibmpa.UUCP Reply-To: lmb@ibmsupt.UUCP (Larry Breed) Organization: IBM AWD Palo Alto Lines: 22 A good compiler will produce better code for the naive algorithm than can be produced for any xor technique. Here's the code generated by the Metaware compiler on AOS (IBM's 4.3 for the rt pc). #void swap(int* i, int* j) _.swap: #{ # int t; # t=*i; ls r0,0(r3) # *i=*j; ls r4,0(r2) sts r0,0(r2) # *j=t; brx r15 # branch with execute of following instruction #} sts r4,0(r3) Disclaimer: Don't blame my employer, blame: Larry Breed (415) 855-4460 uucp: uunet!ibmsupt!lmb inet: ibmsupt!lmb@uunet.uu.net