Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpcc05!hp-ptp!marcb From: marcb@hp-ptp.HP.COM (Marc Brandis) Newsgroups: comp.arch Subject: Re: numeric comparison (was Re: a style question) Message-ID: <1300003@hp-ptp.HP.COM> Date: 4 Oct 90 20:24:19 GMT References: <4147@bingvaxu.cc.binghamton.edu> Organization: HP Pacific Technology Park - Sunnyvale, Ca. Lines: 31 >In article <41898@mips.mips.COM> mash@mips.COM (John Mashey) writes: >:At the code level, this is probably true, although it certainly is the >:case that there are fundamental computer system design reasons why >:== might be faster than <. Whether these reasons show up in any ...... >:It probably doesn't matter most places, except in some technical code >:with short loops with many iterations. > >My point was only that I felt that any performance advantage (one or >two clocks was bandied about) is grossly outweighed by the rest of the >loop, and given that, I tend to prefer the < syntax (since it is pretty >much required for floating-point variables.) Probably you should not care too much about it. A smart optimizer may be able detect most of these cases, where < may be replaced by ==, and do the replacement. This is certainly true for loops like for (i = 0; i < n; i++) stat; where stat is known not to change i. (* I speak only for myself. Marc-Michael Brandis Institut fuer Computersysteme ETH Zentrum CH-8092 Zuerich, Switzerland e-mail: brandis@inf.ethz.ch brandis@iis.ethz.ch Temporarily at HP, marcb@hp-ptp.ptp.hp.com *)