https://issues.dlang.org/show_bug.cgi?id=12958

--- Comment #3 from David Nadlinger <[email protected]> ---
(In reply to David Bregman from comment #2)
> To do the full thing, I'm pretty sure we essentially need to use addu()
> (inlined of course) to sum the partials.

I agree.

> So here's my proposed solution (below): The overflow checks are written in
> such a way that DMD is able to generate branchless code (I checked the
> assembler).

At first glance, this looks good, but chances are I've missed to check some
other edge cases. To this end, it would be awesome if somebody could write a
quick test harness that verifies random multiplication results using BigInt
arithmetic.

Let me also note that performance does not really matter here, as any such
explicit implementation will be much slower than simply using the appropriate
hardware instructions (mul/seto or mul/jno/mov). LDC will map the functions
onto the respective LLVM intrinsics, and I suppose DMD will do something
similar.

--

Reply via email to