Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeGen] map sqrt libcalls to llvm.sqrt when errno is not set
The LLVM sqrt intrinsic definition changed with: D28797 ...so we don't have to use any relaxed FP settings other than errno handling. This patch sidesteps a question raised in PR27435: https://bugs.llvm.org/show_bug.cgi?id=27435 Is a programmer using __builtin_sqrt() invoking the compiler's intrinsic definition of sqrt or the mathlib definition of sqrt? But we have an answer now: the builtin should match the behavior of the libm function including errno handling. Differential Revision: https://reviews.llvm.org/D39204 llvm-svn: 317031
- Loading branch information
1 parent
0fad6dd
commit 7cb25a8
Showing
4 changed files
with
44 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: %clang_cc1 -fmath-errno -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=HAS_ERRNO | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=NO_ERRNO | ||
|
||
// FIXME: If a builtin is supposed to have identical semantics to its libm twin, then it | ||
// should not be marked "constant" in Builtins.def because that means it can't set errno. | ||
// Note that both runs have 'readnone' on the libcall here. | ||
|
||
float foo(float X) { | ||
// HAS_ERRNO: call float @sqrtf(float | ||
// NO_ERRNO: call float @sqrtf(float | ||
return __builtin_sqrtf(X); | ||
} | ||
|
||
// HAS_ERRNO: declare float @sqrtf(float) [[ATTR:#[0-9]+]] | ||
// HAS_ERRNO: attributes [[ATTR]] = { nounwind readnone {{.*}}} | ||
|
||
// NO_ERRNO: declare float @sqrtf(float) [[ATTR:#[0-9]+]] | ||
// NO_ERRNO: attributes [[ATTR]] = { nounwind readnone {{.*}}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters