diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-01-23 20:06:05 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-01-23 20:06:05 +0000 |
commit | d4192f71b5eeb482b4e0a32cb2099f89a5165142 (patch) | |
tree | 8b83cd80f9be04260ad14470badb9675a89fa4a3 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | b2daec9b047df29faa90cb020be4bde9df1c489d (diff) | |
download | bcm5719-llvm-d4192f71b5eeb482b4e0a32cb2099f89a5165142.tar.gz bcm5719-llvm-d4192f71b5eeb482b4e0a32cb2099f89a5165142.zip |
Simplify some code with no functionality change. Make the test a lot more
robust against smarter optimizations, using the power of FileCheck.
llvm-svn: 124081
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 0f2afb2096c..e3fcb8428e8 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -904,15 +904,11 @@ const SCEV *ScalarEvolution::getZeroExtendExpr(const SCEV *Op, // so, we should be able to simplify this further. const SCEV *X = ST->getOperand(); ConstantRange CR = getUnsignedRange(X); - unsigned OrigBits = CR.getBitWidth(); unsigned TruncBits = getTypeSizeInBits(ST->getType()); unsigned NewBits = getTypeSizeInBits(Ty); if (CR.truncate(TruncBits).zeroExtend(NewBits).contains( - CR.zextOrTrunc(NewBits))) { - if (NewBits > OrigBits) return getZeroExtendExpr(X, Ty); - if (NewBits < OrigBits) return getTruncateExpr(X, Ty); - return X; - } + CR.zextOrTrunc(NewBits))) + return getTruncateOrZeroExtend(X, Ty); } // If the input value is a chrec scev, and we can prove that the value @@ -1062,15 +1058,11 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op, // so, we should be able to simplify this further. const SCEV *X = ST->getOperand(); ConstantRange CR = getSignedRange(X); - unsigned OrigBits = CR.getBitWidth(); unsigned TruncBits = getTypeSizeInBits(ST->getType()); unsigned NewBits = getTypeSizeInBits(Ty); if (CR.truncate(TruncBits).signExtend(NewBits).contains( - CR.sextOrTrunc(NewBits))) { - if (NewBits > OrigBits) return getSignExtendExpr(X, Ty); - if (NewBits < OrigBits) return getTruncateExpr(X, Ty); - return X; - } + CR.sextOrTrunc(NewBits))) + return getTruncateOrSignExtend(X, Ty); } // If the input value is a chrec scev, and we can prove that the value |