Optimizing math code

7 messages
Open this post in threaded view
|

Optimizing math code

Open this post in threaded view
|

Re: Optimizing math code

 On Feb 17, 2014, at 8:10 PM, Michael Hamburg <[hidden email]> wrote: > First, addition.  I have multiprecision integer objects, and I’d like to add them component-wise (likewise, subtract, negate, mask…).  For example: > > struct mp { > int limb[8]; > } __attribute__((aligned(32))) ; > > void add(struct mp *a, const struct mp *b, const struct mp *c) { >    for (int i=0; i<8; i++) a->limb[i] = b->limb[i] + c->limb[i]; > } If the struct represents an integer, shouldn't the add take the carry into account? -- Stephen Checkoway _______________________________________________ LLVM Developers mailing list [hidden email]         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Open this post in threaded view
|

Re: Optimizing math code

 On Feb 17, 2014, at 6:38 PM, Stephen Checkoway <[hidden email]> wrote: > > On Feb 17, 2014, at 8:10 PM, Michael Hamburg <[hidden email]> wrote: > >> First, addition.  I have multiprecision integer objects, and I’d like to add them component-wise (likewise, subtract, negate, mask…).  For example: >> >> struct mp { >> int limb[8]; >> } __attribute__((aligned(32))) ; >> >> void add(struct mp *a, const struct mp *b, const struct mp *c) { >>   for (int i=0; i<8; i++) a->limb[i] = b->limb[i] + c->limb[i]; >> } > > If the struct represents an integer, shouldn't the add take the carry into account? Yes.  However, I’m using a redundant representation, with 56-bit digits in a 64-bit limb.  (The real code uses uint64_t’s instead of ints.)  That way up to 8 bits of carries can accumulate, and I can propagate them all at a more opportune time. Cheers, — Mike _______________________________________________ LLVM Developers mailing list [hidden email]         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Open this post in threaded view
|

Re: Optimizing math code

 In reply to this post by Mike Hamburg-3 On Feb 17, 2014, at 5:10 PM, Michael Hamburg <[hidden email]> wrote: Even in a trivial case, I can’t convince either clang-3.3 orClang3.3 is really old. Please try the latest LLVM. _______________________________________________ LLVM Developers mailing list [hidden email]         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Open this post in threaded view
|

Re: Optimizing math code

 On Feb 17, 2014, at 9:19 PM, Nadav Rotem <[hidden email]> wrote: > > On Feb 17, 2014, at 5:10 PM, Michael Hamburg <[hidden email]> wrote: > >>  Even in a trivial case, I can’t convince either clang-3.3 or > > > Clang3.3 is really old. Please try the latest LLVM. Same result on clang version 3.5 (trunk 201542). -- Mike _______________________________________________ LLVM Developers mailing list [hidden email]         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev