[cfe-dev] [request] Improve debugging of ffast-math optimizations
Gonzalo BG via cfe-dev
cfe-dev at lists.llvm.org
Fri Apr 22 02:48:21 PDT 2016
Finding which code is responsible for violating -ffast-math assumptions is
a very tedious task that I do not wish to anybody.
Right now when a fast-math assumption is violated the only way I have to
debug it is to disable fast math, and step-by-step try each of the more
fine grained math optimizations until I find the minimal combination that
reproduces the issue. This typically allows me to guess which kinds of
operations I should be looking for, and start bisecting. Needles to say
this is extremely time consuming. There must be a better way.
I would like the behavior of all my programs to not change _much_ under the
influence of fast math. The only way to achieve this is to manually perform
the transformations that fast math is going to perform, like exploiting
associativity, and obviously, never violate any of fast-math assumptions.
It would be nice to have a warning that detects e.g. associativity
transformations, and suggest how to rewrite them to minimize difference in
the results between a program compiled with and without fast-math.
There is a tool called Herbie [0] that is used by the rust-herbie-lint [1]
(worht seeing in action) to improve the accuracy and stability of
mathematical operations so maybe something similar could be done to detect
some of the transformations that fast-math does and suggest them to the
user.
At run-time I would like some kind of fast-math sanitizer that catches all
cases in which fast-math assumptions are violated (signaling nans, signed
zeros, ...). Since the undefined-behavior sanitzer already covers e.g.
division by zero, maybe a fast-math check would belong there as well.
[0] http://herbie.uwplse.org/
[1] https://github.com/mcarton/rust-herbie-lint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160422/78794608/attachment.html>
More information about the cfe-dev
mailing list