summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-04-09 17:01:49 +0000
committerNikita Popov <nikita.ppv@gmail.com>2019-04-09 17:01:49 +0000
commit4b2323d1a3d39a35c467a77474d346958aa3eeb7 (patch)
tree98e91ad373b100b1d975917d7c58e3559fe9ab77 /llvm/lib/Analysis
parentd7cc0ec5819784e060523234ee39e129c98041ac (diff)
downloadbcm5719-llvm-4b2323d1a3d39a35c467a77474d346958aa3eeb7.tar.gz
bcm5719-llvm-4b2323d1a3d39a35c467a77474d346958aa3eeb7.zip
[ValueTracking] Use computeConstantRange() for signed sub overflow determination
This is the same change as D60420 but for signed sub rather than signed add: Range information is intersected into the known bits result, allows to detect more no/always overflow conditions. Differential Revision: https://reviews.llvm.org/D60469 llvm-svn: 358020
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1407f24e93b..944de24a5cb 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4192,12 +4192,10 @@ OverflowResult llvm::computeOverflowForSignedSub(const Value *LHS,
ComputeNumSignBits(RHS, DL, 0, AC, CxtI, DT) > 1)
return OverflowResult::NeverOverflows;
- KnownBits LHSKnown = computeKnownBits(LHS, DL, 0, AC, CxtI, DT);
- KnownBits RHSKnown = computeKnownBits(RHS, DL, 0, AC, CxtI, DT);
- ConstantRange LHSRange =
- ConstantRange::fromKnownBits(LHSKnown, /*signed*/ true);
- ConstantRange RHSRange =
- ConstantRange::fromKnownBits(RHSKnown, /*signed*/ true);
+ ConstantRange LHSRange = computeConstantRangeIncludingKnownBits(
+ LHS, /*ForSigned=*/true, DL, /*Depth=*/0, AC, CxtI, DT);
+ ConstantRange RHSRange = computeConstantRangeIncludingKnownBits(
+ RHS, /*ForSigned=*/true, DL, /*Depth=*/0, AC, CxtI, DT);
return mapOverflowResult(LHSRange.signedSubMayOverflow(RHSRange));
}
OpenPOWER on IntegriCloud