]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commit
optimize clamped uadd functions
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:41 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:41 +0000 (11:23 -0700)
commit5034ce882ff4ab49fc4a874009ce638b377bcdaa
tree83e00a143a6741136b8150f0073e20b6b7d1cbd3
parentce18b4a333b1d0e757ba3e9b3f650f5d860f35c9
optimize clamped uadd functions

For unsigned adds, if there's no overflow, the result will be larger
or equal than either source operand. Consequently, if there's an
overflow, the result will be smaller than both, and checking against
one source operand is sufficient. Found accidentally...
(With just one comparison, gcc is in fact able to figure out the
comparison is really the same as the add overflowing and will omit
the comparison. But it won't do this with two comparisons.)
open-vm-tools/lib/include/clamped.h