Converting floor to rint

Gabriel Dos Reis gdr@integrable-solutions.net
Wed Nov 6 14:55:00 GMT 2002


Jan Hubicka <jh@suse.cz> writes:

| On the related note.  How bad would you consider converting
| floor(x) into rint(x-0.5) in the fast-math mode?

If you think you do want to do that transformation, then I would
prefer this

  floor(x) -> nearbyint(x-0.5)

| That transformation would do a miracles for i386, where rint is faster
| than floor by quite a lot and should suffice for 3D application in
| reliablility.  I can imagine it to fail only for very large numbers...

Not really.  floor(1) == 1 and rint(1 - 0.5) maybe be 0 or 1 depending
on the current rounding mode.

I don't think that I really like that transformation, even under
-funsafe-math.  But I would like to hear other people opinons.

-- Gaby



More information about the Gcc-patches mailing list