This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: wish: optimize (x > 0.) floating point comparison.
- To: yotam_medini at avanticorp dot com
- Subject: Re: wish: optimize (x > 0.) floating point comparison.
- From: Robert L Krawitz <rlk at tiac dot net>
- Date: Tue, 22 Sep 1998 16:04:20 -0400
- Cc: egcs at cygnus dot com
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