Bug in std::floor?

Xi Ruoyao ryxi@stu.xidian.edu.cn
Fri Nov 10 10:24:00 GMT 2017


On 2017-11-10 05:58 +0100, Marc Glisse wrote:
> On Fri, 10 Nov 2017, Nil Geisweiller wrote:
> > Indeed! I would really like to have a look at the floor implementation, but 
> > it has proven difficult. It calls __builtin_floor, that is no where to be 
> > found. It seems to be implemented in gcc/builtins.c but it's too obfuscated 
> > for me to understand.
> 
> Look at the generated asm? Here, it is a single instruction: roundsd.
> For constant folding, you would want to look at real.c.
> builtins.c essentially delegates the work to each target to specify how 
> floor should be expanded, and generates a call to the system's C library 
> when that's not specified.
> 
I found a machine independent version in glibc and slightly modified it
(expanding some macros and removing optimization barriers).  It's attached.
-- 
Xi Ruoyao <ryxi@stu.xidian.edu.cn>
School of Aerospace Science and Technology, Xidian University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: floor.c
Type: text/x-csrc
Size: 2294 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20171110/75aaa9c0/attachment-0001.bin>


More information about the Gcc-help mailing list