wish: optimize (x > 0.) floating point comparison.

Robert L Krawitz rlk@tiac.net
Tue Sep 22 14:32:00 GMT 1998


   Date: Tue, 22 Sep 1998 08:55:30 -0700
   From: Yotam Medini <yotam@avanticorp.com>

   My assembly-code reading skill is very poor.
   Still, given:
       double x;
   and viewing the code generated (gcc -S -O?) I think the following
   two logical expressions
	  (x >= 0.)
	  (x >= 13.)
   result with the same computational complexity.

   I believe that floating-point comparisons (<, >, <=, >=) with 0.0 is
   very frequent and worth the trouble of optimizing using the sign bit
   within the (platform dependent) floating-point representation or some
   other machine instruction.

That's not correct.  Consider -0.0 (all zeroes in the mantissa and
exponent, 1 in the sign bit).  This should compare >= 0 (it is, after
all, mathematically equal to zero).  Furthermore, it would not take an
exception if the bits do not in fact represent a valid number.

-- 
Robert Krawitz <rlk@tiac.net>	       http://www.tiac.net/users/rlk/

Tall Clubs International  --  http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail lpf@uunet.uu.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton



More information about the Gcc mailing list