Revision 95310a080bffd5cc0d5708f3356998ad521303ff authored by Keno Fischer on 27 February 2019, 23:05:39 UTC, committed by Keno Fischer on 28 February 2019, 03:31:15 UTC
Any constants produced during inference must be *exact* (in the === to
what would have been produced at runtime sense). As a result, we disallow
constant folding the sqrt intrinsic, since we can't guarantee that this
will be the case (depending on what LLVM decides to do). However, this does
not apply to the optimizer (and in fact we do it all the time by inlining
pure functions here). Thus, for code size, inlining heuristics and non-LLVM
backends, enable the optimizer to constant fold sqrt.

Before:
```
julia> f() = sqrt(2)
f (generic function with 1 method)

julia> @code_typed f()
CodeInfo(
1 ─ %1 = Base.Math.sqrt_llvm(2.0)::Float64
└──      return %1
) => Float64

julia> @code_typed optimize=false f()
CodeInfo(
1 ─ %1 = Main.sqrt(2)::Float64
└──      return %1
) => Float64
```

After
```
julia> @code_typed f()
CodeInfo(
1 ─     return 1.4142135623730951
) => Float64

julia> @code_typed optimize=false f()
CodeInfo(
1 ─ %1 = Main.sqrt(2)::Float64
└──      return %1
) => Float64
```

Note that we are not able to infer `Const`, but still inline the
constant in the optimized version of the IR.
1 parent 0424938
History
File Mode Size
.circleci
.github
base
contrib
deps
doc
etc
src
stdlib
test
ui
.freebsdci.sh -rwxr-xr-x 1.2 KB
.gitattributes -rw-r--r-- 67 bytes
.gitignore -rw-r--r-- 235 bytes
.mailmap -rw-r--r-- 9.5 KB
.travis.yml -rw-r--r-- 6.9 KB
CONTRIBUTING.md -rw-r--r-- 20.5 KB
DISTRIBUTING.md -rw-r--r-- 23.6 KB
HISTORY.md -rw-r--r-- 238.0 KB
LICENSE.md -rw-r--r-- 5.1 KB
Make.inc -rw-r--r-- 36.4 KB
Makefile -rw-r--r-- 28.3 KB
NEWS.md -rw-r--r-- 2.0 KB
README.arm.md -rw-r--r-- 5.7 KB
README.md -rw-r--r-- 29.3 KB
README.windows.md -rw-r--r-- 13.0 KB
VERSION -rw-r--r-- 10 bytes
Windows.inc -rw-r--r-- 1.5 KB
appveyor.yml -rw-r--r-- 2.6 KB

README.md

back to top