bondhugula / pluto

Pluto: An automatic polyhedral parallelizer and locality optimizer
http://pluto-compiler.sourceforge.net
MIT License
268 stars 65 forks source link

Fix ceild and floord definitions #78

Closed nmnobre closed 4 years ago

nmnobre commented 4 years ago

Generated code currently uses floating-point division to implement the ceiling and floor functions. This may lead to incorrect results if -ffast-math is used (in conjuction w/ a -O level >0) to compile such code.

Steps to reproduce:

w/ -ffast-math, (int) floor(((double)(41516))/((double)(107))) is 387 but 41516/107 = 388.

This patch replaces the current definitions with cloog's, which use integer division only.

bondhugula commented 4 years ago

Thanks very much for fixing this!