aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-27 20:32:06 +0000
committerChris Lattner <sabre@nondot.org>2010-08-27 20:32:06 +0000
commit14d6636726b8cc079894d456bd43cf661e571d81 (patch)
tree4b52d50bad0f775cb0f752343f51638d09b6eb76 /lib/Transforms
parent0aeae4baebe1e9a1f51703a9e86f1a01b5c44b84 (diff)
downloadexternal_llvm-14d6636726b8cc079894d456bd43cf661e571d81.zip
external_llvm-14d6636726b8cc079894d456bd43cf661e571d81.tar.gz
external_llvm-14d6636726b8cc079894d456bd43cf661e571d81.tar.bz2
teach the truncation optimization that an entire chain of
computation can be truncated if it is fed by a sext/zext that doesn't have to be exactly equal to the truncation result type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCasts.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 1372a18..89719be 100644
--- a/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -396,6 +396,11 @@ static bool CanEvaluateTruncated(Value *V, const Type *Ty) {
case Instruction::Trunc:
// trunc(trunc(x)) -> trunc(x)
return true;
+ case Instruction::ZExt:
+ case Instruction::SExt:
+ // trunc(ext(x)) -> ext(x) if the source type is smaller than the new dest
+ // trunc(ext(x)) -> trunc(x) if the source type is larger than the new dest
+ return true;
case Instruction::Select: {
SelectInst *SI = cast<SelectInst>(I);
return CanEvaluateTruncated(SI->getTrueValue(), Ty) &&