[llvm-dev] multiprecision add/sub
Bagel via llvm-dev
llvm-dev at lists.llvm.org
Wed Feb 15 14:22:38 PST 2017
I suggest that LLVM needs intrinsics for add/sub with carry, e.g.
declare {T, i1} @llvm.addc.T(T %a, T %b, i1 c)
The current multiprecision clang intrinsics example:
void foo(unsigned *x, unsigned *y, unsigned *z)
{ unsigned carryin = 0;
unsigned carryout;
z[0] = __builtin_addc(x[0], y[0], carryin, &carryout);
carryin = carryout;
z[1] = __builtin_addc(x[1], y[1], carryin, &carryout);
carryin = carryout;
z[2] = __builtin_addc(x[2], y[2], carryin, &carryout);
carryin = carryout;
z[3] = __builtin_addc(x[3], y[3], carryin, &carryout);
}
uses the LLVM intrinsic "llvm.uadd.with.overflow" and generates
horrible code that doesn't use the "adc" x86 instruction.
What is the current thinking on improving multiprecision arithmetic?
More information about the llvm-dev
mailing list