[Support] Fix SaturatingMultiply<T>() to be correct (and fast), Re-enable Unit Tests
authorNathan Slingerland <slingn@gmail.com>
Mon, 23 Nov 2015 15:33:43 +0000 (15:33 +0000)
committerNathan Slingerland <slingn@gmail.com>
Mon, 23 Nov 2015 15:33:43 +0000 (15:33 +0000)
commitf2bc179203d0e17bfcfa28bd5b9c1ba1d04cd6fe
treed402a0134412a9b9cc0951f2326f7234c5d28c41
parente5c2c47f2fbe37712e50765d405e17cc46694e12
[Support] Fix SaturatingMultiply<T>() to be correct (and fast), Re-enable Unit Tests

Summary:
This change fixes the SaturatingMultiply<T>() function template to not cause undefined behavior with T=uint16_t.
Thanks to Richard Smith's contribution, it also no longer requires an integer division.

Patch by Richard Smith.

Reviewers: silvas, davidxl

Subscribers: rsmith, davidxl, llvm-commits

Differential Revision: http://reviews.llvm.org/D14845

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253870 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/MathExtras.h
unittests/Support/MathExtrasTest.cpp