This is an archive of the discontinued LLVM Phabricator instance.

[libc][math] Implement full multiplication and quick_mul_hi for UInt class.
ClosedPublic

Authored by lntue on Nov 22 2022, 8:42 PM.

Details

Summary

Implement full multiplication UInt<A> * UInt<B> -> UInt<A + B> and
quick_mul_hi that returns the higher half of the product UInt<A> * UInt<A>.
These 2 functions will be used for dyadic floating point class.

Diff Detail

Event Timeline

lntue created this revision.Nov 22 2022, 8:42 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 22 2022, 8:42 PM
lntue requested review of this revision.Nov 22 2022, 8:42 PM
lntue edited the summary of this revision. (Show Details)Nov 22 2022, 8:45 PM
sivachandra added inline comments.Nov 30 2022, 12:41 AM
libc/src/__support/UInt.h
219

Can you add more commentary here explaining how this is different from operator*? IIUC, operator* returns the LS Bits of the result, while this is will return the MS Bits of the result with an additional condition that the LS-Bit of the result need not be the same as that in the MS Bits of the result produced by ful_mul.

libc/test/src/__support/uint_test.cpp
510

Please fix.

libc/utils/UnitTest/LibcTest.cpp
294

While OK for this change, I think this is going beyond manageable limits. We should refactor the test infrastructure with some urgency so that we can put these specializations next to the special types.

lntue updated this revision to Diff 479307.Dec 1 2022, 8:31 AM

Add comments about error bounds and efficiency of quick_mul_hi + More tests.

sivachandra accepted this revision.Dec 2 2022, 11:12 AM
sivachandra added inline comments.
libc/src/__support/UInt.h
219

Add an example of where this kind of multiplication will be useful.

This revision is now accepted and ready to land.Dec 2 2022, 11:12 AM
This revision was automatically updated to reflect the committed changes.
lntue marked an inline comment as done.