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
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 @@
// 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 @@
// 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