[llvm-commits] [llvm] r69809 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Dan Gohman
gohman at apple.com
Wed Apr 22 09:20:50 PDT 2009
Author: djg
Date: Wed Apr 22 11:20:48 2009
New Revision: 69809
URL: http://llvm.org/viewvc/llvm-project?rev=69809&view=rev
Log:
Simplify trivial cast-of-cast SCEVs.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=69809&r1=69808&r2=69809&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Apr 22 11:20:48 2009
@@ -654,6 +654,10 @@
return getUnknown(
ConstantExpr::getTrunc(SC->getValue(), Ty));
+ // trunc(trunc(x)) --> trunc(x)
+ if (SCEVTruncateExpr *ST = dyn_cast<SCEVTruncateExpr>(Op))
+ return getTruncateExpr(ST->getOperand(), Ty);
+
// If the input value is a chrec scev made out of constants, truncate
// all of the constants.
if (SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Op)) {
@@ -685,6 +689,10 @@
return getUnknown(C);
}
+ // zext(zext(x)) --> zext(x)
+ if (SCEVZeroExtendExpr *SZ = dyn_cast<SCEVZeroExtendExpr>(Op))
+ return getZeroExtendExpr(SZ->getOperand(), Ty);
+
// FIXME: If the input value is a chrec scev, and we can prove that the value
// did not overflow the old, smaller, value, we can zero extend all of the
// operands (often constants). This would allow analysis of something like
@@ -706,6 +714,10 @@
return getUnknown(C);
}
+ // sext(sext(x)) --> sext(x)
+ if (SCEVSignExtendExpr *SS = dyn_cast<SCEVSignExtendExpr>(Op))
+ return getSignExtendExpr(SS->getOperand(), Ty);
+
// FIXME: If the input value is a chrec scev, and we can prove that the value
// did not overflow the old, smaller, value, we can sign extend all of the
// operands (often constants). This would allow analysis of something like
More information about the llvm-commits
mailing list