Fix rare case where APInt divide algorithm applied un-needed transformation.
authorYaron Keren <yaron.keren@gmail.com>
Thu, 26 Mar 2015 19:45:19 +0000 (19:45 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Thu, 26 Mar 2015 19:45:19 +0000 (19:45 +0000)
commit61ac65ddec9becc4b6773077c69f0f54b942e445
treef1dee8a2ef269445044c0b5e2059d28937e1f2c9
parent784545fba0e1fcbb5e12cde76d13d91fd0972323
Fix rare case where APInt divide algorithm applied un-needed transformation.

APInt uses Knuth's D algorithm for long division. In rare cases the
implementation applied a transformation that was not needed.

Added unit tests for long division. KnuthDiv() procedure is fully covered.
There is a case in APInt::divide() that I believe is never used (marked with
a comment) as all users of divide() handle trivial cases earlier.

Patch by Pawel Bylica!

  http://reviews.llvm.org/D8448

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233312 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/APInt.cpp
unittests/ADT/APIntTest.cpp