diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index 79e552da58da4..56f23ca7c2b39 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -618,7 +618,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 diff --git a/test/compiler/inline.jl b/test/compiler/inline.jl index a5991b5436e70..9283a3101e7e3 100644 --- a/test/compiler/inline.jl +++ b/test/compiler/inline.jl @@ -891,3 +891,7 @@ let ftest(a) = (fcond(a, nothing); a) @test fully_eliminated(ftest, Tuple{Bool}) end + +# sqrt not considered volatile +f_sqrt() = sqrt(2) +@test fully_eliminated(f_sqrt, Tuple{}) diff --git a/test/math.jl b/test/math.jl index 4904677a3ddf3..6f45b18f2636d 100644 --- a/test/math.jl +++ b/test/math.jl @@ -1386,8 +1386,10 @@ end # Runtime version @test sqrt(x) === y # Interpreter compile-time version + @test Base.invokelatest((@eval ()->sqrt(Base.inferencebarrier($x)))) == y + # Inference const-prop version @test Base.invokelatest((@eval ()->sqrt($x))) == y # LLVM constant folding version - @test Base.invokelatest((@eval ()->(@force_compile; sqrt($x)))) == y + @test Base.invokelatest((@eval ()->(@force_compile; sqrt(Base.inferencebarrier($x))))) == y end end