Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Wed, 26 Sep 2012 11:51:10 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: Swapping logic References: <49f36538-d5ca-411c-bc58-1f17b55911b6@s8g2000vbc.googlegroups.com> <87ehlpnxot.fsf@gmail.com> Date: Wed, 26 Sep 2012 17:51:15 +0100 Message-ID: <87y5jwlocc.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ENN+DCInw7bKg+V8b0aV22HYjlg= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 31 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-VJXpcV6+w/DEXtTjj/90a10HUVvkQhQ1porjPemeJTJWEy+vtihaXLFJSQvkFIrO4VA30Y+MOh4e/iG!osUpa2QoMXNNM3lAtK+V/YnIJqREKJuruzfNeo2+zSRGGdzkRKuFhQYYAaScc8Q6XRbS X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2457 Xref: csiph.com comp.lang.c:26713 David Brown writes: > When you have particular specialised needs, you have to work very > closely with the compiler - playing with command line switches and > code layout, and analysing the exact generated assembly code. For > small embedded systems, or very time-critical code, many rules no > longer apply Right. I agree completely. When Eric said "Don't do this", he implicitly meant "Don't do this unless you really, really know why you". Writing fancy-dan XOR exchange routines without first proving they're necessary is classic premature optimisation, and we all know what premature optimisation is. > But for general programming - as done by the majority of programmers > for the majority of the time - rules like this apply. Right. I agree completely. (And I speak as someone who's spent the day trying to squeeze individual clock cycles out of an ARM7 routine because the proprietary compiler does not optimise well -- the kind of day when you're profiling branch probabilities to determine which branch is the hot path, but have no way to communicate this to the compiler, which has decided that no matter what you it's going to guess wrong :( ). I freaking hate *compiler name elided*