[LLVMdev] Optimization of sqrt() with invalid argument

Tim Northover t.p.northover at gmail.com
Fri Sep 26 08:38:11 PDT 2014


> We should fix it because it costs us nothing to do and conforms to IEEE-754, and there’s no good reason to maintain the current behavior.

Probably, but there are theoretical issues: 0 is easier for other
optimisations to deal with than NaN (especially after constant
propagation). It's also creating NaNs in situations where they've been
explicitly disabled (the @llvm.sqrt intrinsic only really gets created
in finite math mode). In my perfect world we'd optimise it to a
segfault.

I doubt anything bad will actually happen though, so I'm not actually
bothered one way or the other; just vaguely annoyed that compilers get
changed to accommodate broken benchmarks (well, more accurately, to
allow us to sneak a -ffast-math compile into our numbers when the
benchmark wasn't designed for it).

Cheers.

Tim.




More information about the llvm-dev mailing list