summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-07-23 20:33:29 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-07-23 20:33:29 +0000
commitb42729b53a061e2a3def61eb10e2a648cecd60ae (patch)
treeb85c046d83efb6af717a2259dae2ecacd80a765e /lib/Support
parent5e31044e119c75899b91ca97eb4d8ba786afc01c (diff)
downloadllvm-b42729b53a061e2a3def61eb10e2a648cecd60ae.tar.gz
llvm-b42729b53a061e2a3def61eb10e2a648cecd60ae.tar.bz2
llvm-b42729b53a061e2a3def61eb10e2a648cecd60ae.tar.xz
make ConstantRange::zeroExtend() optimal
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/ConstantRange.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp
index a3f2297596..720ef36c46 100644
--- a/lib/Support/ConstantRange.cpp
+++ b/lib/Support/ConstantRange.cpp
@@ -427,9 +427,13 @@ ConstantRange ConstantRange::zeroExtend(uint32_t DstTySize) const {
unsigned SrcTySize = getBitWidth();
assert(SrcTySize < DstTySize && "Not a value extension");
- if (isFullSet() || isWrappedSet())
+ if (isFullSet() || isWrappedSet()) {
// Change into [0, 1 << src bit width)
- return ConstantRange(APInt(DstTySize,0), APInt(DstTySize,1).shl(SrcTySize));
+ APInt LowerExt(DstTySize, 0);
+ if (!Upper) // special case: [X, 0) -- not really wrapping around
+ LowerExt = Lower.zext(DstTySize);
+ return ConstantRange(LowerExt, APInt(DstTySize, 1).shl(SrcTySize));
+ }
return ConstantRange(Lower.zext(DstTySize), Upper.zext(DstTySize));
}