summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/math-builtins.c
Commit message (Collapse)AuthorAgeFilesLines
* [clang] Handle lrint/llrint builtinsAdhemerval Zanella2019-05-281-6/+6
| | | | | | | | | | | | As for other floating-point rounding builtins that can be optimized when build with -fno-math-errno, this patch adds support for lrint and llrint. It currently only optimize for AArch64 backend. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D62019 llvm-svn: 361878
* [Intrinsics] Merge lround.i32 and lround.i64 into a single intrinsic with ↵Craig Topper2019-05-201-3/+3
| | | | | | | | | | overloaded result type. Make result type for llvm.llround overloaded instead of fixing to i64 We shouldn't really make assumptions about possible sizes for long and long long. And longer term we should probably support vectorizing these intrinsics. By making the result types not fixed we can support vectors as well. Differential Revision: https://reviews.llvm.org/D62026 llvm-svn: 361169
* [clang] Handle lround/llround builtinsAdhemerval Zanella2019-05-161-6/+6
| | | | | | | | | | | | As for other floating-point rounding builtins that can be optimized when build with -fno-math-errno, this patch adds support for lround and llround. It currently only optimize for AArch64 backend. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D61392 llvm-svn: 360896
* [CodeGen] make nan builtins pure rather than const (PR37778)Sanjay Patel2018-06-131-17/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | https://bugs.llvm.org/show_bug.cgi?id=37778 ...shows a miscompile resulting from marking nan builtins as 'const'. The nan libcalls/builtins take a pointer argument: http://www.cplusplus.com/reference/cmath/nan-function/ ...and the chars dereferenced by that arg are used to fill in the NaN constant payload bits. "const" means that the pointer argument isn't dereferenced. That's translated to "readnone" in LLVM. "pure" means that the pointer argument may be dereferenced. That's translated to "readonly" in LLVM. This change prevents the IR optimizer from killing the lead-up to the nan call here: double a() { char buf[4]; buf[0] = buf[1] = buf[2] = '9'; buf[3] = '\0'; return __builtin_nan(buf); } ...the optimizer isn't currently able to simplify this to a constant as we might hope, but this patch should solve the miscompile. Differential Revision: https://reviews.llvm.org/D48134 llvm-svn: 334628
* [CodeGen] Mark fma as const for AndroidPirama Arumuga Nainar2018-03-261-0/+6
| | | | | | | | | | | | | | | Summary: r318093 sets fma, fmaf, fmal as const for Gnu and MSVC. Android also does not set errno for these functions. So mark these const for Android. Reviewers: spatel, efriedma, srhines, chh, enh Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D44852 llvm-svn: 328552
* Add support for a limited subset of TS 18661-3 math builtins.Benjamin Kramer2018-01-061-6/+14
| | | | | | | | | | | | | | | | | These just overloads for _Float128. They're supported by GCC 7 and used by glibc. APFloat support is already there so just add the overloads. __builtin_copysignf128 __builtin_fabsf128 __builtin_huge_valf128 __builtin_inff128 __builtin_nanf128 __builtin_nansf128 This is the same support that GCC has, according to the documentation, but limited to _Float128. llvm-svn: 321948
* [CodeGen] fix mapping from fmod calls to frem instructionSanjay Patel2017-12-021-8/+10
| | | | | | Similar to D40044 and discussed in D40594. llvm-svn: 319619
* [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsicsSanjay Patel2017-12-011-24/+24
| | | | | | | | | | | | | | | | There are 20 LLVM math intrinsics that correspond to mathlib calls according to the LangRef: http://llvm.org/docs/LangRef.html#standard-c-library-intrinsics We were only converting 3 mathlib calls (sqrt, fma, pow) and 12 builtin calls (ceil, copysign, fabs, floor, fma, fmax, fmin, nearbyint, pow, rint, round, trunc) to their intrinsic-equivalents. This patch pulls the transforms together and handles all 20 cases. The switch is guarded by a check for const-ness to make sure we're not doing the transform if errno could possibly be set by the libcall or builtin. Differential Revision: https://reviews.llvm.org/D40044 llvm-svn: 319593
* [CodeGen] fix const-ness of cbrt and fmaSanjay Patel2017-11-131-6/+22
| | | | | | | | | | | cbrt() is always constant because it can't overflow or underflow. Therefore, it can't set errno. fma() is not always constant because it can overflow or underflow. Therefore, it can set errno. But we know that it never sets errno on GNU / MSVC, so make it constant in those environments. Differential Revision: https://reviews.llvm.org/D39641 llvm-svn: 318093
* [CodeGen] split math and complex tests into separate files; NFCISanjay Patel2017-11-071-0/+560
The files are already large, and we may need to add even more RUNs to distinguish differences based on OS, environment, or other platform things. llvm-svn: 317583
OpenPOWER on IntegriCloud