Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcsun!ukc!warwick!cudcv From: cudcv@warwick.ac.uk (Rob McMahon) Newsgroups: comp.lang.c Subject: Re: swap(x,y) Message-ID: <184@titania.warwick.ac.uk> Date: 25 Aug 89 19:30:05 GMT References: <8350@boring.cwi.nl> <8514@galbp.LBP.HARRIS.COM> <3040@solo5.cs.vu.nl> <32074@ism780c.isc.com> Reply-To: cudcv@warwick.ac.uk (Rob McMahon) Organization: Computing Services, Warwick University, UK Lines: 26 Re: x += y; y = x - y; x -= y; vs. x ^= y; y ^= x; x ^= y; vs. tmp = x; x = y; y = tmp; Surely this is another of these things that should be coded legibly and left to the compiler to do the best way, rather than trying to guess what operations the current machine has, and whether the compiler has put variables in memory or registers etc. Lets talk about how to improve the compilers first. On our Gould PN6000 with GCC 1.34 { int tmp; tmp = x; x = y; y = tmp; } compiles to xchg r5,r4 Rob -- UUCP: ...!mcvax!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick ARPA: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England