summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/ConstantRange.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-29 05:08:52 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-29 05:08:52 +0000
commitee4f22dc2df40fbc42672a0677ac4d11f245bc48 (patch)
tree5f5f4b749e997f8bdb8f7d206f0d0281b02d6a1b /llvm/lib/IR/ConstantRange.cpp
parent1f961df10c7f523266a5f66a228aade82110ab11 (diff)
downloadbcm5719-llvm-ee4f22dc2df40fbc42672a0677ac4d11f245bc48.tar.gz
bcm5719-llvm-ee4f22dc2df40fbc42672a0677ac4d11f245bc48.zip
[ConstantRange] Improve the efficiency of one of the ConstantRange constructors.
We were default constructing the Lower/Upper APInts. Then creating min or max value, then doing a move assignment to Lower and copy assignment to upper. The copy assignment operator in particular has an out of line function call that has to examine whether or not a previous allocation exists that can be reused which of course it can't in this case. The new code creates the min/max value first, move constructs Lower from it then copy constructs Upper from Lower. This also seems to have convinced a self host build that this constructor can be inlined more readily into other methods in ConstantRange. llvm-svn: 301736
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 072a9a96635..bd2581b4003 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -29,12 +29,9 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-ConstantRange::ConstantRange(uint32_t BitWidth, bool Full) {
- if (Full)
- Lower = Upper = APInt::getMaxValue(BitWidth);
- else
- Lower = Upper = APInt::getMinValue(BitWidth);
-}
+ConstantRange::ConstantRange(uint32_t BitWidth, bool Full)
+ : Lower(Full ? APInt::getMaxValue(BitWidth) : APInt::getMinValue(BitWidth)),
+ Upper(Lower) {}
ConstantRange::ConstantRange(APInt V)
: Lower(std::move(V)), Upper(Lower + 1) {}
OpenPOWER on IntegriCloud