forked from OSchip/llvm-project
73e8a784e6
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 |
||
---|---|---|
.. | ||
2007-01-31-RegInfoAssert.ll | ||
2007-02-02-JoinIntervalsCrash.ll | ||
2007-05-05-InvalidPushPop.ll | ||
2009-06-18-ThumbCommuteMul.ll | ||
2009-07-20-TwoAddrBug.ll | ||
2009-07-27-PEIAssert.ll | ||
2009-08-12-ConstIslandAssert.ll | ||
2009-08-12-RegInfoAssert.ll | ||
2009-08-20-ISelBug.ll | ||
2009-12-17-pre-regalloc-taildup.ll | ||
2010-06-18-SibCallCrash.ll | ||
2010-07-01-FuncAlign.ll | ||
2010-07-15-debugOrdering.ll | ||
2011-05-11-DAGLegalizer.ll | ||
2011-06-16-NoGPRs.ll | ||
2011-EpilogueBug.ll | ||
2012-04-26-M0ISelBug.ll | ||
2014-06-10-thumb1-ldst-opt-bug.ll | ||
DbgValueOtherTargets.test | ||
PR17309.ll | ||
PR35481.ll | ||
PR36658.mir | ||
addr-modes.ll | ||
and_neg.ll | ||
asmprinter-bug.ll | ||
barrier.ll | ||
bic_imm.ll | ||
branchless-cmp.ll | ||
callee_save.ll | ||
cmp-add-fold.ll | ||
cmp-fold.ll | ||
constants.ll | ||
copy_thumb.ll | ||
cortex-m0-unaligned-access.ll | ||
dyn-stackalloc.ll | ||
fastcc.ll | ||
fpconv.ll | ||
fpow.ll | ||
frame-access.ll | ||
frame_thumb.ll | ||
i8-phi-ext.ll | ||
iabs.ll | ||
inlineasm-imm-thumb.ll | ||
inlineasm-thumb.ll | ||
ispositive.ll | ||
large-stack.ll | ||
ldm-merge-call.ll | ||
ldm-merge-struct.ll | ||
ldm-stm-base-materialization-thumb2.ll | ||
ldm-stm-base-materialization.ll | ||
ldm-stm-postinc.ll | ||
ldr_ext.ll | ||
ldr_frame.ll | ||
lit.local.cfg | ||
litpoolremat.ll | ||
long-setcc.ll | ||
long.ll | ||
long_shift.ll | ||
machine-cse-physreg.mir | ||
mature-mc-support.ll | ||
mul.ll | ||
mvn.ll | ||
optionaldef-scheduling.ll | ||
pop.ll | ||
pr35836.ll | ||
pr35836_2.ll | ||
push.ll | ||
remove-unneeded-push-pop.ll | ||
rev.ll | ||
segmented-stacks-dynamic.ll | ||
segmented-stacks.ll | ||
select.ll | ||
shift-and.ll | ||
sjljehprepare-lower-vector.ll | ||
stack-access.ll | ||
stack-coloring-without-frame-ptr.ll | ||
stack-frame.ll | ||
stack_guard_remat.ll | ||
stm-deprecated.ll | ||
stm-merge.ll | ||
stm-scavenging.ll | ||
tbb-reuse.mir | ||
thumb-imm.ll | ||
thumb-ldm.ll | ||
thumb-shrink-wrapping.ll | ||
thumb1-cmp.ll | ||
trap.ll | ||
triple.ll | ||
tst_teq.ll | ||
umulo-128-legalisation-lowering.ll | ||
unord.ll | ||
vargs.ll |