Skip to content

Commit

Permalink
RFC: Remove sqrt from the volatile list
Browse files Browse the repository at this point in the history
The LLVM IR spec now explicitly says that this intrinsic is required
to be rounded correctly. That means that without fasthmath flag
(which we do not set here), this intrinsic must have the bitwise
correctly rounded answer and should thus not differ between compile
and runtime. If there is still a case where it does differ, that is
likely some other underlying bug that we should fix instead.

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
```

After:
```
julia> @code_typed f()
CodeInfo(
1 ─     return 1.4142135623730951
) => Float64
```
  • Loading branch information
Keno committed Jan 12, 2022
1 parent 8997a90 commit 7922ce9
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ function is_pure_intrinsic_infer(f::IntrinsicFunction)
f === Intrinsics.pointerset || # this one is never effect-free
f === Intrinsics.llvmcall || # this one is never effect-free
f === Intrinsics.arraylen || # this one is volatile
f === Intrinsics.sqrt_llvm || # this one may differ at runtime (by a few ulps)
f === Intrinsics.sqrt_llvm_fast || # this one may differ at runtime (by a few ulps)
f === Intrinsics.have_fma || # this one depends on the runtime environment
f === Intrinsics.cglobal) # cglobal lookup answer changes at runtime
Expand Down

0 comments on commit 7922ce9

Please sign in to comment.