1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 12:33:33 +02:00
Go to file
Craig Topper b6f26d8003 [APInt] Reduce number of allocations involved in multiplying. Reduce worst case multiply size
Currently multiply is implemented in operator*=. Operator* makes a copy and uses operator*= to modify the copy.

Operator*= itself allocates a temporary buffer to hold the multiply result as it computes it. Then copies it to the buffer in *this.

Operator*= attempts to bound the size of the result based on the number of active bits in its inputs. It also has a couple special cases to handle 0 inputs without any memory allocations or multiply operations. The best case is that it calculates a single word regardless of input bit width. The worst case is that it calculates the a 2x input width result and drop the upper bits.

Since operator* uses operator*= it incurs two allocations, one for a copy of *this and one for the temporary allocation. Neither of these allocations are kept after the method operation is done.

The main usage in the backend appears to be ConstantRange::multiply which uses operator* rather than operator*=.

This patch moves the multiply operation to operator* and implements operator*= using it. This avoids the copy in operator*. operator* now allocates a result buffer sized the same width as its inputs no matter what. This buffer will be used as the buffer for the returned APInt. Finally, we reuse tcMultiply to implement the multiply operation. This function is capable of not calculating additional upper words that will be discarded.

This change does lose the special optimizations for the inputs using less words than their size implies. But it also removed the getActiveBits calls from all multiplies. If we think those optimizations are important we could look at providing additional bounds to tcMultiply to limit the computations.

Differential Revision: https://reviews.llvm.org/D32830

llvm-svn: 302171
2017-05-04 17:00:41 +00:00
bindings [go bindings] Rmove duplicated conversion function definitions after r300843. 2017-04-20 19:06:11 +00:00
cmake Revert "CMake: Move sphinx detection into AddSphinxTarget.cmake" 2017-05-03 17:22:23 +00:00
docs [Lexicon] Add BDCE 2017-05-04 16:50:37 +00:00
examples Module::getOrInsertFunction is using C-style vararg instead of variadic templates. 2017-04-11 15:01:18 +00:00
include [globalisel][tablegen] Add several GINodeEquiv's for operators that do not require additional support. 2017-05-04 14:24:50 +00:00
lib [APInt] Reduce number of allocations involved in multiplying. Reduce worst case multiply size 2017-05-04 17:00:41 +00:00
projects [cmake] Include openmp with add_llvm_external_project 2017-03-07 18:54:17 +00:00
resources In MSVC builds embed a VERSIONINFO resource in our exe and DLL files. 2015-06-12 15:58:29 +00:00
runtimes [CMake][runtimes] Use -nodefaultlibs for the runtimes build 2017-04-13 21:29:03 +00:00
test [PM] Add ProfileSummaryAnalysis as a required pass in the new pipeline. 2017-05-04 16:58:45 +00:00
tools Revert "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI." 2017-05-04 11:49:39 +00:00
unittests [AArch64] Make the TargetParser add CPU exts provided by the arch. 2017-05-03 20:33:58 +00:00
utils [test-release] Status update *before* long gzip 2017-05-04 16:21:30 +00:00
.arcconfig project_id is from another era in phabricator land and does not provide any value. 2016-09-27 15:47:29 +00:00
.clang-format Test commit. 2014-03-02 13:08:46 +00:00
.clang-tidy .clang-tidy: correct style name is 'camelBack' not 'lowerCase'. 2016-09-13 19:04:26 +00:00
.gitignore gitignore: Ignore .vs folder (VS2017 config files) 2017-04-08 00:16:58 +00:00
CMakeLists.txt CMake: Add LLVM_DYLIB_SYMBOL_VERSIONING option 2017-05-03 14:43:44 +00:00
CODE_OWNERS.TXT CODE_OWNERS: Take code ownership of instruction scheduling. 2017-03-10 18:34:37 +00:00
configure Remove autoconf support 2016-01-26 21:29:08 +00:00
CREDITS.TXT CODE_OWNERS: Take code ownership of instruction scheduling. 2017-03-10 18:34:37 +00:00
LICENSE.TXT Bump year to 2017 in LICENSE.txt 2017-01-12 18:02:42 +00:00
llvm.spec.in [Sparc] Implement i64 load/store support for 32-bit sparc. 2015-08-10 19:11:39 +00:00
LLVMBuild.txt
README.txt Test commit. Added a blank line. 2017-03-06 20:45:33 +00:00
RELEASE_TESTERS.TXT Update the release tester for MIPS. NFC. 2017-01-17 11:00:28 +00:00

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.