diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-23 20:33:29 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-23 20:33:29 +0000 |
commit | eb9d2755b20f9874b5cf77d77d7b5692628d93ea (patch) | |
tree | 94737ce65cd8e6503db3a6a89245dd95b5067218 /llvm/lib/Support | |
parent | 1feac1cef9bba99d0832eac9a58084cb90c669d8 (diff) | |
download | bcm5719-llvm-eb9d2755b20f9874b5cf77d77d7b5692628d93ea.tar.gz bcm5719-llvm-eb9d2755b20f9874b5cf77d77d7b5692628d93ea.zip |
make ConstantRange::zeroExtend() optimal
llvm-svn: 160643
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/ConstantRange.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp index a3f22975963..720ef36c464 100644 --- a/llvm/lib/Support/ConstantRange.cpp +++ b/llvm/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)); } |