Revision ca4375b5c0d273e2bb11c381a4f51cc0a7b139ad authored by Keno Fischer on 27 February 2019, 23:05:39 UTC, committed by Tim Besard on 17 December 2020, 11:07:36 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 1fdca23
File | Mode | Size |
---|---|---|
.devcontainer | ||
base | ||
cli | ||
contrib | ||
deps | ||
doc | ||
etc | ||
src | ||
stdlib | ||
test | ||
.clang-format | -rw-r--r-- | 3.3 KB |
.gitattributes | -rw-r--r-- | 65 bytes |
.gitignore | -rw-r--r-- | 283 bytes |
.mailmap | -rw-r--r-- | 11.0 KB |
CITATION.bib | -rw-r--r-- | 2.6 KB |
CONTRIBUTING.md | -rw-r--r-- | 19.9 KB |
HISTORY.md | -rw-r--r-- | 292.0 KB |
LICENSE.md | -rw-r--r-- | 5.0 KB |
Make.inc | -rw-r--r-- | 49.1 KB |
Makefile | -rw-r--r-- | 24.6 KB |
NEWS.md | -rw-r--r-- | 21.1 KB |
README.md | -rw-r--r-- | 6.9 KB |
VERSION | -rw-r--r-- | 10 bytes |
sysimage.mk | -rw-r--r-- | 3.9 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...