[ValueTracking] Use computeConstantRange() for unsigned add/sub overflow
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 19 Mar 2019 17:53:56 +0000 (17:53 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 19 Mar 2019 17:53:56 +0000 (17:53 +0000)
commit208381953b29fb796438083958c66c2b9fa90baa
tree9d51500972e7f014f4fa8d15103172d343d786b3
parentafd1a23ffb213277139cf8c15023f327635433bb
[ValueTracking] Use computeConstantRange() for unsigned add/sub overflow

Improve computeOverflowForUnsignedAdd/Sub in ValueTracking by
intersecting the computeConstantRange() result into the ConstantRange
created from computeKnownBits(). This allows us to detect some
additional never/always overflows conditions that can't be determined
from known bits.

This revision also adds basic handling for constants to
computeConstantRange(). Non-splat vectors will be handled in a followup.

The signed case will also be handled in a followup, as it needs some
more groundwork.

Differential Revision: https://reviews.llvm.org/D59386

llvm-svn: 356489
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/and2.ll
llvm/test/Transforms/InstCombine/saturating-add-sub.ll
llvm/test/Transforms/InstCombine/uadd-with-overflow.ll
llvm/test/Transforms/LoopVectorize/X86/small-size.ll