On Sun, Jul 17, 2016 at 01:54:57PM -0700, Arthur O'Dwyer via cfe-commits wrote: > IMHO, if replacing "%" with "fastmod" in general-purpose code like this > were a good idea, > (A) libc++ should introduce a helper function __fastmod(m,n) for the > purpose, not repeat the same patch everywhere there's currently a "%" > operator; and/or > (B) someone with authority over the Clang x86 backend > (*cough*Chandler*cough*) should look into improving the codegen for "%" by > auto-detecting when it might make sense to use this heuristic.
As I mentioned to Eric, the better idea is likely to just precompute the multiplicative inverse and shift and just use the two multiplication version instead. At least for compilers with basic uint128_t support or on 32bit platforms, that's a definite win. It's not an optimisation the compiler can do as it requires additional storage. Joerg _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits