a style question
    Chris Torek 
    chris at mimsy.umd.edu
       
    Mon Oct  1 19:57:47 AEST 1990
    
    
  
[on the test `x < 100' vs `x != 100' in a for loop]
In article <DAVIS.90Oct1025438 at pacific.mps.ohio-state.edu>
davis at pacific.mps.ohio-state.edu ("John E. Davis") writes:
>Which generates faster code?  It seems to me that it is easier to tell if
>two values are unequal than to tell if one is greater than the other.
Not really.  The easy comparisons are against 0; the others are generally
a bit harder.  (A comparison for `x == y' can be done in more ways than
one for `x < y', but this is not much of a recommendation.)  Look at the
test instructions on the current crop of fast CPUs for a demonstration.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris
    
    
More information about the Comp.lang.c
mailing list