summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-04-22 16:20:48 +0000
committerDan Gohman <gohman@apple.com>2009-04-22 16:20:48 +0000
commit79af854f55496442fb5e64f39975d3f99ceef176 (patch)
tree4dfa468e22045ec5f5d4b2191c2fce4538e0bae4 /llvm
parent54fd2869a3b6d3e1d11a45b39c77953356c3476d (diff)
downloadbcm5719-llvm-79af854f55496442fb5e64f39975d3f99ceef176.tar.gz
bcm5719-llvm-79af854f55496442fb5e64f39975d3f99ceef176.zip
Simplify trivial cast-of-cast SCEVs.
llvm-svn: 69809
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 75331fdab49..cebf4d704fe 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -654,6 +654,10 @@ SCEVHandle ScalarEvolution::getTruncateExpr(const SCEVHandle &Op, const Type *Ty
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 @@ SCEVHandle ScalarEvolution::getZeroExtendExpr(const SCEVHandle &Op,
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 @@ SCEVHandle ScalarEvolution::getSignExtendExpr(const SCEVHandle &Op, const Type *
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
OpenPOWER on IntegriCloud