From d4192f71b5eeb482b4e0a32cb2099f89a5165142 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 23 Jan 2011 20:06:05 +0000 Subject: 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 --- llvm/lib/Analysis/ScalarEvolution.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp') 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 -- cgit v1.2.3