[llvm-dev] multiprecision add/sub
Brian Smith via llvm-dev
llvm-dev at lists.llvm.org
Wed Feb 15 16:24:11 PST 2017
Stephen Canon via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Why do you think this requires new intrinsics instead of teaching the optimizer what to do with the existing intrinsics?
IMO, as a multiprecision math library maker, the "teaching the
optimizer what to do with the existing intrinsics" approach is much
better as long as it can be made to work. If one is careful, MSVC does
optimize its intrinsics into ADC instructions in a reasonable way, so
I think it is probably doable.
(Below, all math is multiprecision.)
There are actually a few different operations besides pure addition
and subtraction, e.g. `a - (b >> 1)` instead of just `a - b`. Also
consider that we sometimes want "a - b" to be side-channel free and
other times we'd rather "a - b" to be as fast as possible and
optimized for the case where carries are unlikely to propagate (far).
That's already three different operations, just for subtraction.
More information about the llvm-dev