This is an archive of the discontinued LLVM Phabricator instance.

Fix APInt long division algorithm
ClosedPublic

Authored by chfast on Apr 22 2015, 8:18 AM.

Details

Summary

This patch fixes step D4 of Knuth's division algorithm implementation. Negative sign of the step result was not always detected due to incorrect "borrow" handling.

Diff Detail

Repository
rL LLVM

Event Timeline

chfast updated this revision to Diff 24230.Apr 22 2015, 8:18 AM
chfast retitled this revision from to Fix APInt long division algorithm.
chfast updated this object.
chfast edited the test plan for this revision. (Show Details)
chfast added a reviewer: chandlerc.
chfast set the repository for this revision to rL LLVM.
chfast added a subscriber: Unknown Object (MLST).

Hi Yaron,

You reviewed my previous fix in the algorithm, so you might be interested.

yaron.keren edited edge metadata.Apr 22 2015, 9:41 AM

I'll have a look.

How do you find these bugs? by reviewing the code, fuzzing the inputs, or?

2015-04-22 18:31 GMT+03:00 Paweł Bylica <chfast@gmail.com>:

Hi Yaron,

You reviewed my previous fix in the algorithm, so you might be interested.

REPOSITORY

rL LLVM

http://reviews.llvm.org/D9196

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/
yaron.keren added inline comments.Apr 22 2015, 10:10 AM
unittests/ADT/APIntTest.cpp
307

Please factor this code segment to a helper function, it's the same in divrem_big1, divrem_big2, divrem_big3, divrem_big5 and divrem_big6.

How do you find these bugs? by reviewing the code, fuzzing the inputs, or?

By fuzzy tests of my project that uses a lot of 256 and 512 bit arithmetic.

chfast updated this revision to Diff 24269.Apr 23 2015, 12:05 AM
chfast edited edge metadata.

Unit tests refactored

yaron.keren accepted this revision.Apr 24 2015, 12:11 AM
yaron.keren edited edge metadata.

Ok, this LGTM. Commit the patch?

This revision is now accepted and ready to land.Apr 24 2015, 12:11 AM

Ok, this LGTM. Commit the patch?

I can handle it myself now. Thanks for the review.

chfast closed this revision.Apr 24 2015, 12:37 AM