Go to file
Chandler Carruth a216cad0fc [complex] Teach Clang to preserve different-type operands to arithmetic
operators where one type is a C complex type, and to emit both the
efficient and correct implementation for complex arithmetic according to
C11 Annex G using this extra information.

For both multiply and divide the old code was writing a long-hand
reduced version of the math without any of the special handling of inf
and NaN recommended by the standard here. Instead of putting more
complexity here, this change does what GCC does which is to emit
a libcall for the fully general case.

However, the old code also failed to do the proper minimization of the
set of operations when there was a mixed complex and real operation. In
those cases, C provides a spec for much more minimal operations that are
valid. Clang now emits the exact suggested operations. This change isn't
*just* about performance though, without minimizing these operations, we
again lose the correct handling of infinities and NaNs. It is critical
that this happen in the frontend based on assymetric type operands to
complex math operations.

The performance implications of this change aren't trivial either. I've
run a set of benchmarks in Eigen, an open source mathematics library
that makes heavy use of complex. While a few have slowed down due to the
libcall being introduce, most sped up and some by a huge amount: up to
100% and 140%.

In order to make all of this work, also match the algorithm in the
constant evaluator to the one in the runtime library. Currently it is
a broken port of the simplifications from C's Annex G to the long-hand
formulation of the algorithm.

Splitting this patch up is very hard because none of this works without
the AST change to preserve non-complex operands. Sorry for the enormous
change.

Follow-up changes will include support for sinking the libcalls onto
cold paths in common cases and fastmath improvements to allow more
aggressive backend folding.

Differential Revision: http://reviews.llvm.org/D5698

llvm-svn: 219557
2014-10-11 00:57:18 +00:00
clang [complex] Teach Clang to preserve different-type operands to arithmetic 2014-10-11 00:57:18 +00:00
clang-tools-extra Small cleanups from review comments. 2014-10-09 13:22:46 +00:00
compiler-rt [asan][mips] Adding support of asan for mipsel arch 2014-10-10 13:46:55 +00:00
debuginfo-tests Properly shutdown lldb by invoking SBDebugger_Terminate() 2014-10-09 22:16:46 +00:00
libclc Implement log1p builtin 2014-10-07 20:22:42 +00:00
libcxx Fix for PR 19616: 'tuple_cat of nested tuples fails in noexcept specification'. Thanks to Louis Dionne for the fix. 2014-10-07 21:42:12 +00:00
libcxxabi Use __atomic_exchange_n instead of Clang's __sync_swap 2014-10-03 20:03:47 +00:00
lld Reapply [ELF] Only mark as DT_NEEDED libs that are strictly necessary (r219353) 2014-10-09 22:06:38 +00:00
lldb include compiler-rt in build-llvm.pl 2014-10-11 00:53:32 +00:00
llvm Add basic conditional branches in mips fast-isel 2014-10-11 00:55:18 +00:00
openmp I apologise in advance for the size of this check-in. At Intel we do 2014-10-07 16:25:50 +00:00
polly Relax the condition on the jsop accesses regarding the alignment. 2014-10-10 15:14:29 +00:00