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 | 76167af9b1968b2824fcb76db0bc571f422035b4 (patch) | |
tree | b69ffb3b11535d0aeae64c1c52ff5313ff2cb8ea /lib/Analysis/ScalarEvolution.cpp | |
parent | dd0dfdf8beea667769fe00cd5a7126404922dbab (diff) | |
download | external_llvm-76167af9b1968b2824fcb76db0bc571f422035b4.zip external_llvm-76167af9b1968b2824fcb76db0bc571f422035b4.tar.gz external_llvm-76167af9b1968b2824fcb76db0bc571f422035b4.tar.bz2 |
Simplify some code with no functionality change. Make the test a lot more
robust against smarter optimizations, using the power of FileCheck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 0f2afb2..e3fcb84 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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 |