diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-10 20:30:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-10 20:30:41 +0000 |
commit | 11ea81242473027c67395e9e94396f4e2a282dda (patch) | |
tree | c0cfca19ce99f6a0da2bf503dc96f5bab86d61ef /lib/Transforms/InstCombine/InstCombineCasts.cpp | |
parent | 9ee947c224a157a5fb2c921a0e194fddedef2f9f (diff) |
teach sext optimization to handle truncs from types that are not
the dest of the sext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCasts.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp index e2e74c1e5d..49b2e22a68 100644 --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -799,6 +799,10 @@ static bool CanEvaluateSExtd(Value *V, const Type *Ty, TargetData *TD) { if (!I->hasOneUse()) return false; switch (I->getOpcode()) { + case Instruction::SExt: // sext(sext(x)) -> sext(x) + case Instruction::ZExt: // sext(zext(x)) -> zext(x) + case Instruction::Trunc: // sext(trunc(x)) -> trunc(x) or sext(x) + return true; case Instruction::And: case Instruction::Or: case Instruction::Xor: @@ -813,9 +817,6 @@ static bool CanEvaluateSExtd(Value *V, const Type *Ty, TargetData *TD) { //case Instruction::LShr: TODO //case Instruction::Trunc: TODO - case Instruction::SExt: // sext(sext(x)) -> sext(x) - case Instruction::ZExt: // sext(zext(x)) -> zext(x) - return true; case Instruction::Select: return CanEvaluateSExtd(I->getOperand(1), Ty, TD) && CanEvaluateSExtd(I->getOperand(2), Ty, TD); |