[APInt] Optimize umul_ov
authorFangrui Song <maskray@google.com>
Fri, 19 Apr 2019 02:06:06 +0000 (02:06 +0000)
committerFangrui Song <maskray@google.com>
Fri, 19 Apr 2019 02:06:06 +0000 (02:06 +0000)
commitacc7641bcb9df243e7c2e0e8c4636929e21642e8
treed83e501952ef4e055f288699cbb06b59aeac0fee
parent9206335e9d100e65f85a73168400875839405f20
[APInt] Optimize umul_ov

Change two costly udiv() calls to lshr(1)*RHS + left-shift + plus

On one 64-bit umul_ov benchmark, I measured an obvious improvement: 12.8129s -> 3.6257s

Note, there may be some value to special case 64-bit (the most common
case) with __builtin_umulll_overflow().

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

llvm-svn: 358730
llvm/lib/Support/APInt.cpp
llvm/unittests/ADT/APIntTest.cpp