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
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index e2e74c1..49b2e22 100644
--- a/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -799,6 +799,10 @@
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 @@
//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);