summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-04 00:06:55 +0000
committerChris Lattner <sabre@nondot.org>2011-01-04 00:06:55 +0000
commit7c90b90f4e9b0c421f0e45d7de03f6edce113a90 (patch)
treee41d639ba8f4b10b84a7af7dfae48e122a1fa14b /lib/Transforms/Scalar/LoopIdiomRecognize.cpp
parent2c502f915f52aab994fce7d3e78d1d021321d7a5 (diff)
downloadllvm-7c90b90f4e9b0c421f0e45d7de03f6edce113a90.tar.gz
llvm-7c90b90f4e9b0c421f0e45d7de03f6edce113a90.tar.bz2
llvm-7c90b90f4e9b0c421f0e45d7de03f6edce113a90.tar.xz
use the very-handy getTruncateOrZeroExtend helper function, and
stop setting NSW: signed overflow is possible. Thanks to Dan for pointing these out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122790 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIdiomRecognize.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopIdiomRecognize.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 52fc2636ac..fc707755e9 100644
--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -349,17 +349,13 @@ processLoopStoreOfSplatValue(StoreInst *SI, unsigned StoreSize,
// The # stored bytes is (BECount+1)*Size. Expand the trip count out to
// pointer size if it isn't already.
const Type *IntPtr = TD->getIntPtrType(SI->getContext());
- unsigned BESize = SE->getTypeSizeInBits(BECount->getType());
- if (BESize < TD->getPointerSizeInBits())
- BECount = SE->getZeroExtendExpr(BECount, IntPtr);
- else if (BESize > TD->getPointerSizeInBits())
- BECount = SE->getTruncateExpr(BECount, IntPtr);
+ BECount = SE->getTruncateOrZeroExtend(BECount, IntPtr);
const SCEV *NumBytesS = SE->getAddExpr(BECount, SE->getConstant(IntPtr, 1),
- true, true /*nooverflow*/);
+ true /*no unsigned overflow*/);
if (StoreSize != 1)
NumBytesS = SE->getMulExpr(NumBytesS, SE->getConstant(IntPtr, StoreSize),
- true, true /*nooverflow*/);
+ true /*no unsigned overflow*/);
Value *NumBytes =
Expander.expandCodeFor(NumBytesS, IntPtr, Preheader->getTerminator());
@@ -426,17 +422,13 @@ processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
// The # stored bytes is (BECount+1)*Size. Expand the trip count out to
// pointer size if it isn't already.
const Type *IntPtr = TD->getIntPtrType(SI->getContext());
- unsigned BESize = SE->getTypeSizeInBits(BECount->getType());
- if (BESize < TD->getPointerSizeInBits())
- BECount = SE->getZeroExtendExpr(BECount, IntPtr);
- else if (BESize > TD->getPointerSizeInBits())
- BECount = SE->getTruncateExpr(BECount, IntPtr);
+ BECount = SE->getTruncateOrZeroExtend(BECount, IntPtr);
const SCEV *NumBytesS = SE->getAddExpr(BECount, SE->getConstant(IntPtr, 1),
- true, true /*nooverflow*/);
+ true /*no unsigned overflow*/);
if (StoreSize != 1)
NumBytesS = SE->getMulExpr(NumBytesS, SE->getConstant(IntPtr, StoreSize),
- true, true /*nooverflow*/);
+ true /*no unsigned overflow*/);
Value *NumBytes =
Expander.expandCodeFor(NumBytesS, IntPtr, Preheader->getTerminator());