This is an archive of the discontinued LLVM Phabricator instance.

Intrin: Add _umul128
ClosedPublic

Authored by majnemer on Dec 2 2014, 2:59 PM.

Details

Summary

Implement _umul128; it provides the high and low halves of a 128-bit
multiply. We can simply use our __int128 arithmetic to implement this,
we generate great code for it:

movq    %rdx, %rax
mulq    %rcx
movq    %rdx, (%r8)
retq

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 16830.Dec 2 2014, 2:59 PM
majnemer retitled this revision from to Intrin: Add _umul128.
majnemer updated this object.
majnemer added reviewers: rnk, hansw, thakis.
majnemer added a subscriber: Unknown Object (MLST).
hans accepted this revision.Dec 2 2014, 3:09 PM
hans added a reviewer: hans.
hans added a subscriber: hans.

lgtm with comment

lib/Headers/Intrin.h
419 ↗(On Diff #16830)

While you're here, is shrx_u64 missing an underscore?

423 ↗(On Diff #16830)

use an underscore for FullProduct to be safe?

This revision is now accepted and ready to land.Dec 2 2014, 3:09 PM
rnk accepted this revision.Dec 2 2014, 3:19 PM
rnk edited edge metadata.

lgtm

Nice!

lib/Headers/Intrin.h
423 ↗(On Diff #16830)

Why not unsigned __int128? I believe this affects the shift right below, but all the bits that would be 1 are truncated out.

majnemer closed this revision.Dec 2 2014, 3:30 PM
majnemer updated this revision to Diff 16837.

Closed by commit rL223175 (authored by @majnemer).