aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 6629ca840a67..58f0763bb0c0 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -103,6 +103,16 @@ Value *InstCombinerImpl::EvaluateInDifferentType(Value *V, Type *Ty,
}
}
break;
+ case Instruction::ShuffleVector: {
+ auto *ScalarTy = cast<VectorType>(Ty)->getElementType();
+ auto *VTy = cast<VectorType>(I->getOperand(0)->getType());
+ auto *FixedTy = VectorType::get(ScalarTy, VTy->getElementCount());
+ Value *Op0 = EvaluateInDifferentType(I->getOperand(0), FixedTy, isSigned);
+ Value *Op1 = EvaluateInDifferentType(I->getOperand(1), FixedTy, isSigned);
+ Res = new ShuffleVectorInst(Op0, Op1,
+ cast<ShuffleVectorInst>(I)->getShuffleMask());
+ break;
+ }
default:
// TODO: Can handle more cases here.
llvm_unreachable("Unreachable!");
@@ -363,6 +373,9 @@ static bool canEvaluateTruncated(Value *V, Type *Ty, InstCombinerImpl &IC,
I->getOpcode() == Instruction::FPToSI);
return Ty->getScalarSizeInBits() >= MinBitWidth;
}
+ case Instruction::ShuffleVector:
+ return canEvaluateTruncated(I->getOperand(0), Ty, IC, CxtI) &&
+ canEvaluateTruncated(I->getOperand(1), Ty, IC, CxtI);
default:
// TODO: Can handle more cases here.
break;