1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 12:33:33 +02:00
llvm-mirror/test
Eli Friedman ca89c6b055 [SelectionDAG] Improve the legalisation lowering of UMULO.
There is no way in the universe, that doing a full-width division in
software will be faster than doing overflowing multiplication in
software in the first place, especially given that this same full-width
multiplication needs to be done anyway.

This patch replaces the previous implementation with a direct lowering
into an overflowing multiplication algorithm based on half-width
operations.

Correctness of the algorithm was verified by exhaustively checking the
output of this algorithm for overflowing multiplication of 16 bit
integers against an obviously correct widening multiplication. Baring
any oversights introduced by porting the algorithm to DAG, confidence in
correctness of this algorithm is extremely high.

Following table shows the change in both t = runtime and s = space. The
change is expressed as a multiplier of original, so anything under 1 is
“better” and anything above 1 is worse.

+-------+-----------+-----------+-------------+-------------+
| Arch  | u64*u64 t | u64*u64 s | u128*u128 t | u128*u128 s |
+-------+-----------+-----------+-------------+-------------+
|   X64 |     -     |     -     |    ~0.5     |    ~0.64    |
|  i686 |   ~0.5    |   ~0.6666 |    ~0.05    |    ~0.9     |
| armv7 |     -     |   ~0.75   |      -      |    ~1.4     |
+-------+-----------+-----------+-------------+-------------+

Performance numbers have been collected by running overflowing
multiplication in a loop under `perf` on two x86_64 (one Intel Haswell,
other AMD Ryzen) based machines. Size numbers have been collected by
looking at the size of function containing an overflowing multiply in
a loop.

All in all, it can be seen that both performance and size has improved
except in the case of armv7 where code size has regressed for 128-bit
multiply. u128*u128 overflowing multiply on 32-bit platforms seem to
benefit from this change a lot, taking only 5% of the time compared to
original algorithm to calculate the same thing.

The final benefit of this change is that LLVM is now capable of lowering
the overflowing unsigned multiply for integers of any bit-width as long
as the target is capable of lowering regular multiplication for the same
bit-width. Previously, 128-bit overflowing multiply was the widest
possible.

Patch by Simonas Kazlauskas!

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

llvm-svn: 339922
2018-08-16 18:39:39 +00:00
..
Analysis [ConstantFolding] add tests for funnel shift intrinsics; NFC 2018-08-16 16:10:42 +00:00
Assembler [DebugInfoMetadata] Added DIFlags interface in DIBasicType. 2018-08-14 19:35:34 +00:00
Bindings
Bitcode [ThinLTO] Handle optional args in assembly format for ConstVCalls 2018-08-14 01:49:33 +00:00
BugPoint
CodeGen [SelectionDAG] Improve the legalisation lowering of UMULO. 2018-08-16 18:39:39 +00:00
DebugInfo [codeview] Use push_macro to avoid conflicts instead of a prefix 2018-08-16 17:34:31 +00:00
Demangle [MS Demangler] Demangle string literals. 2018-08-16 16:17:36 +00:00
Examples
ExecutionEngine
Feature
FileCheck
Instrumentation [BFI] Use rounding while computing profile counts. 2018-08-16 00:26:59 +00:00
Integer
JitListener
Linker
LTO
MC [codeview] Use push_macro to avoid conflicts instead of a prefix 2018-08-16 17:34:31 +00:00
Object
ObjectYAML
Other
SafepointIRVerifier
SymbolRewriter
TableGen
ThinLTO/X86 [ThinLTO] Fix printing of WPD remarks 2018-08-14 03:00:16 +00:00
tools [llvm-strip] Add support for -p/--preserve-dates 2018-08-16 18:29:40 +00:00
Transforms [NFC] Fix typo in test cases 2018-08-16 17:03:22 +00:00
Unit
Verifier
YAMLParser
.clang-format
CMakeLists.txt
lit.cfg.py
lit.site.cfg.py.in
TestRunner.sh