summaryrefslogtreecommitdiff
path: root/lib/IR/ConstantRange.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-26 20:32:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-26 20:32:52 +0000
commit08bbd35a80bf7765fe0d3043f9eb5a2f2786b649 (patch)
tree80108f0f128657f8623f8f66ad9735b4d88e7b47 /lib/IR/ConstantRange.cpp
parent7c7aba6e5fef47a01a136be655b0a92cfd7090f6 (diff)
Notes
Diffstat (limited to 'lib/IR/ConstantRange.cpp')
-rw-r--r--lib/IR/ConstantRange.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/IR/ConstantRange.cpp b/lib/IR/ConstantRange.cpp
index 21d1996ef851..4bd17257016d 100644
--- a/lib/IR/ConstantRange.cpp
+++ b/lib/IR/ConstantRange.cpp
@@ -1,4 +1,4 @@
-//===-- ConstantRange.cpp - ConstantRange implementation ------------------===//
+//===- ConstantRange.cpp - ConstantRange implementation -------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,12 +21,21 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/APInt.h"
#include "llvm/IR/ConstantRange.h"
+#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Metadata.h"
#include "llvm/IR/Operator.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+
using namespace llvm;
ConstantRange::ConstantRange(uint32_t BitWidth, bool Full)
@@ -170,7 +179,7 @@ ConstantRange
ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
const ConstantRange &Other,
unsigned NoWrapKind) {
- typedef OverflowingBinaryOperator OBO;
+ using OBO = OverflowingBinaryOperator;
// Computes the intersection of CR0 and CR1. It is different from
// intersectWith in that the ConstantRange returned will only contain elements
@@ -284,27 +293,14 @@ APInt ConstantRange::getUnsignedMin() const {
}
APInt ConstantRange::getSignedMax() const {
- if (!isWrappedSet()) {
- APInt UpperMinusOne = getUpper() - 1;
- if (getLower().sle(UpperMinusOne))
- return UpperMinusOne;
- return APInt::getSignedMaxValue(getBitWidth());
- }
- if (getLower().isNegative() == getUpper().isNegative())
+ if (isFullSet() || Lower.sgt(Upper))
return APInt::getSignedMaxValue(getBitWidth());
return getUpper() - 1;
}
APInt ConstantRange::getSignedMin() const {
- if (!isWrappedSet()) {
- if (getLower().sle(getUpper() - 1))
- return getLower();
+ if (isFullSet() || (Lower.sgt(Upper) && !getUpper().isMinSignedValue()))
return APInt::getSignedMinValue(getBitWidth());
- }
- if ((getUpper() - 1).slt(getLower())) {
- if (!getUpper().isMinSignedValue())
- return APInt::getSignedMinValue(getBitWidth());
- }
return getLower();
}