On Sat, 28 May 2016, Alexander Monakov wrote:
For unsigned A, B, 'A > -1 / B' is a nice predicate for checking whether 'A*B' overflows (or 'B && A > -1 / B' if B may be zero). Let's optimize it to an invocation of __builtin_mul_overflow to avoid the divide operation.
I forgot to ask earlier: what does this give for modes / platforms where umulv4 does not have a specific implementation? Is the generic implementation worse than A>-1/B, in which case we may want to check optab_handler before doing the transformation? Or is it always at least as good?
(I didn't ask because I was assuming the latter, but I am not 100% certain)
-- Marc Glisse