[cfe-dev] [request] Improve debugging of ffast-math optimizations

Mehdi Amini via cfe-dev cfe-dev at lists.llvm.org
Sat Apr 23 15:23:51 PDT 2016

> On Apr 22, 2016, at 2:48 AM, Gonzalo BG via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> Finding which code is responsible for violating -ffast-math assumptions is a very tedious task that I do not wish to anybody.

Are these "assumptions" documented anywhere?



> 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/ <https://urldefense.proofpoint.com/v2/url?u=http-3A__herbie.uwplse.org_&d=BQMFaQ&c=Hw-EJUFt2_D9PK5csBJ29kRV40HqSDXWTLPyZ6W8u84&r=XndYjVJuvcoEtO9BUlAZk8839TPlVRJeJXMNUFEz-qQ&m=Tmi-qc9w1RLgfErj01UBb6y4P6pj3ny7eW62vm4wyho&s=GPaqjWrANwjME_GEuZOPegqnVufMG9m-A1B5HEPnDak&e=>
> [1] https://github.com/mcarton/rust-herbie-lint <https://github.com/mcarton/rust-herbie-lint>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160423/3a3be373/attachment.html>

More information about the cfe-dev mailing list