This test used to check that sqrt() did not use the LLVM intrinsic because
its behavior did not match IEEE 754 for negative inputs. That has now
changed in recent versions of LLVM. There are still some differences in
how the LLVM intrinsic handles errno, but that should not affect Swift.
With Clang r319593, the test began to fail because __builtin_sqrtf gets
translated to the LLVM intrinsic. Change the test to match.
* Mark libc math shims with always_inline attribute
We want these to always be inlined, so mark them with ... always_inline.
The compiler happened to do the right thing with them previously, but we
shouldn't depend on that.
<rdar://problem/30043258> master-next: IRGen/builtin_math.swift failing because sqrt(4) is not constant folded
Tracking the problem in rdar://problem/30043258. This check fails:
// CHECK-LABEL: define {{.*}}test5
// CHECK: ret float 2
public func test5( ) -> Float {
return sqrt(4)
}
The IR that we’re generating is:
define float @_TF12builtin_math5test5FT_Sf() #4 {
entry:
%0 = tail call fastcc float @_swift_stdlib_squareRootf(float 4.000000e+00)
ret float %0
}
Note that the Double version in test6 works as expected.
* Go back to using static inline implementations of sqrt and remainder now that SR-2089 is resolved.
* Fix typo: sqrt -> squareRoot.
* Added test for constant-folding sqrt with -O.
* Added test case requested by jrose.
* Use intrinsics instead of Libc stubs where we can.
This replaces most of the stubs used for basic operations on these
types with intrinsics, eliminating a level of indirection for fma,
ceil, floor, round, trunc.
square root and remainder still require stubs because there is no
remainder intrinsic and we can't use the square root intrinsic because
its behavior is undefined for negative inputs. A previous commit
apparently either the compiler annotates static inline stubs wrong
or the SIL verifier can't handle them, so that change was backed out.
* Explicitly CHECK-NOT @llvm.sqrt instead of looking for @sqrt.
This reapplies commit r22864 - it is not changing the public api as we initially
thought. sqrt() was never available without importing Darwin.
This change only changes where sqrt() gets "forwarded" to. Before 'sqrt' called
the builtin '_sqrt' defined in BuiltinMath now it just calls the math library's
'sqrt' function.
I also added a stdlib test.
rdar://18371371
Swift SVN r22870
This is controlled by a new isWholeModule() attribute in SILModule.
It gives about 9% code size reduction on the benchmark executables.
For test-suite reasons it is currently not done for the stdlib.
Swift SVN r22491