OSDN Git Service

[ValueTracking] More accurate unsigned add overflow detection
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 28 Feb 2019 08:11:20 +0000 (08:11 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 28 Feb 2019 08:11:20 +0000 (08:11 +0000)
commit72316b718a15aca441a4434a99be3c221eb87442
tree8b1e2116a5b9cfeb970a40ffe8b18bad747b1927
parent04bfc05d5a56727af51de7cb01a2ade275a7761d
[ValueTracking] More accurate unsigned add overflow detection

Part of D58593.

Compute precise overflow conditions based on all known bits, rather
than just the sign bits. Unsigned a + b overflows iff a > ~b, and we
can determine whether this always/never happens based on the minimal
and maximal values achievable for a and ~b subject to the known bits
constraint.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355072 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ValueTracking.cpp
test/Transforms/InstCombine/AddOverFlow.ll
test/Transforms/InstCombine/add.ll
test/Transforms/InstCombine/saturating-add-sub.ll
test/Transforms/InstCombine/shuffle_select.ll