From: Craig Topper Date: Sun, 30 Apr 2017 00:44:05 +0000 (+0000) Subject: [ConstantRange] Fix a couple cases where we were possibly throwing away an APInt... X-Git-Tag: llvmorg-5.0.0-rc1~6313 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=866165309f3d776ad795bb545383028be3eefa21;p=platform%2Fupstream%2Fllvm.git [ConstantRange] Fix a couple cases where we were possibly throwing away an APInt allocation we could reuse. NFC This uses setAllBits to replace getMaxValue and operator=(uint64_t) instead of constructing an APInt from uint64_t. llvm-svn: 301761 --- diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index 4d7e73eb07fa..5425676e4edc 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -581,7 +581,7 @@ ConstantRange ConstantRange::truncate(uint32_t DstTySize) const { return ConstantRange(DstTySize, /*isFullSet=*/true); Union = ConstantRange(APInt::getMaxValue(DstTySize),Upper.trunc(DstTySize)); - UpperDiv = APInt::getMaxValue(getBitWidth()); + UpperDiv.setAllBits(); // Union covers the MaxValue case, so return if the remaining range is just // MaxValue. @@ -837,7 +837,7 @@ ConstantRange::udiv(const ConstantRange &RHS) const { if (RHS.getUpper() == 1) RHS_umin = RHS.getLower(); else - RHS_umin = APInt(getBitWidth(), 1); + RHS_umin = 1; } APInt Upper = getUnsignedMax().udiv(RHS_umin) + 1;