mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Clean up usages of asserting vector getters in Type
Summary: Remove usages of asserting vector getters in Type in preparation for the VectorType refactor. The existence of these functions complicates the refactor while adding little value. Reviewers: rriddle, sdesmalen, efriedma Reviewed By: efriedma Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77259
This commit is contained in:
parent
a71fe3d3eb
commit
6525db3b03
@ -1913,8 +1913,8 @@ void InnerLoopVectorizer::widenIntOrFpInduction(PHINode *IV, TruncInst *Trunc) {
|
|||||||
Value *InnerLoopVectorizer::getStepVector(Value *Val, int StartIdx, Value *Step,
|
Value *InnerLoopVectorizer::getStepVector(Value *Val, int StartIdx, Value *Step,
|
||||||
Instruction::BinaryOps BinOp) {
|
Instruction::BinaryOps BinOp) {
|
||||||
// Create and check the types.
|
// Create and check the types.
|
||||||
assert(Val->getType()->isVectorTy() && "Must be a vector");
|
auto *ValVTy = cast<VectorType>(Val->getType());
|
||||||
int VLen = Val->getType()->getVectorNumElements();
|
int VLen = ValVTy->getNumElements();
|
||||||
|
|
||||||
Type *STy = Val->getType()->getScalarType();
|
Type *STy = Val->getType()->getScalarType();
|
||||||
assert((STy->isIntegerTy() || STy->isFloatingPointTy()) &&
|
assert((STy->isIntegerTy() || STy->isFloatingPointTy()) &&
|
||||||
@ -3318,13 +3318,14 @@ unsigned LoopVectorizationCostModel::getVectorIntrinsicCost(CallInst *CI,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Type *smallestIntegerVectorType(Type *T1, Type *T2) {
|
static Type *smallestIntegerVectorType(Type *T1, Type *T2) {
|
||||||
auto *I1 = cast<IntegerType>(T1->getVectorElementType());
|
auto *I1 = cast<IntegerType>(cast<VectorType>(T1)->getElementType());
|
||||||
auto *I2 = cast<IntegerType>(T2->getVectorElementType());
|
auto *I2 = cast<IntegerType>(cast<VectorType>(T2)->getElementType());
|
||||||
return I1->getBitWidth() < I2->getBitWidth() ? T1 : T2;
|
return I1->getBitWidth() < I2->getBitWidth() ? T1 : T2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Type *largestIntegerVectorType(Type *T1, Type *T2) {
|
static Type *largestIntegerVectorType(Type *T1, Type *T2) {
|
||||||
auto *I1 = cast<IntegerType>(T1->getVectorElementType());
|
auto *I1 = cast<IntegerType>(cast<VectorType>(T1)->getElementType());
|
||||||
auto *I2 = cast<IntegerType>(T2->getVectorElementType());
|
auto *I2 = cast<IntegerType>(cast<VectorType>(T2)->getElementType());
|
||||||
return I1->getBitWidth() > I2->getBitWidth() ? T1 : T2;
|
return I1->getBitWidth() > I2->getBitWidth() ? T1 : T2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3347,8 +3348,8 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths() {
|
|||||||
Type *OriginalTy = I->getType();
|
Type *OriginalTy = I->getType();
|
||||||
Type *ScalarTruncatedTy =
|
Type *ScalarTruncatedTy =
|
||||||
IntegerType::get(OriginalTy->getContext(), KV.second);
|
IntegerType::get(OriginalTy->getContext(), KV.second);
|
||||||
Type *TruncatedTy = VectorType::get(ScalarTruncatedTy,
|
Type *TruncatedTy = VectorType::get(
|
||||||
OriginalTy->getVectorNumElements());
|
ScalarTruncatedTy, cast<VectorType>(OriginalTy)->getNumElements());
|
||||||
if (TruncatedTy == OriginalTy)
|
if (TruncatedTy == OriginalTy)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -3398,10 +3399,12 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (auto *SI = dyn_cast<ShuffleVectorInst>(I)) {
|
} else if (auto *SI = dyn_cast<ShuffleVectorInst>(I)) {
|
||||||
auto Elements0 = SI->getOperand(0)->getType()->getVectorNumElements();
|
auto Elements0 =
|
||||||
|
cast<VectorType>(SI->getOperand(0)->getType())->getNumElements();
|
||||||
auto *O0 = B.CreateZExtOrTrunc(
|
auto *O0 = B.CreateZExtOrTrunc(
|
||||||
SI->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements0));
|
SI->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements0));
|
||||||
auto Elements1 = SI->getOperand(1)->getType()->getVectorNumElements();
|
auto Elements1 =
|
||||||
|
cast<VectorType>(SI->getOperand(1)->getType())->getNumElements();
|
||||||
auto *O1 = B.CreateZExtOrTrunc(
|
auto *O1 = B.CreateZExtOrTrunc(
|
||||||
SI->getOperand(1), VectorType::get(ScalarTruncatedTy, Elements1));
|
SI->getOperand(1), VectorType::get(ScalarTruncatedTy, Elements1));
|
||||||
|
|
||||||
@ -3410,13 +3413,15 @@ void InnerLoopVectorizer::truncateToMinimalBitwidths() {
|
|||||||
// Don't do anything with the operands, just extend the result.
|
// Don't do anything with the operands, just extend the result.
|
||||||
continue;
|
continue;
|
||||||
} else if (auto *IE = dyn_cast<InsertElementInst>(I)) {
|
} else if (auto *IE = dyn_cast<InsertElementInst>(I)) {
|
||||||
auto Elements = IE->getOperand(0)->getType()->getVectorNumElements();
|
auto Elements =
|
||||||
|
cast<VectorType>(IE->getOperand(0)->getType())->getNumElements();
|
||||||
auto *O0 = B.CreateZExtOrTrunc(
|
auto *O0 = B.CreateZExtOrTrunc(
|
||||||
IE->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements));
|
IE->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements));
|
||||||
auto *O1 = B.CreateZExtOrTrunc(IE->getOperand(1), ScalarTruncatedTy);
|
auto *O1 = B.CreateZExtOrTrunc(IE->getOperand(1), ScalarTruncatedTy);
|
||||||
NewI = B.CreateInsertElement(O0, O1, IE->getOperand(2));
|
NewI = B.CreateInsertElement(O0, O1, IE->getOperand(2));
|
||||||
} else if (auto *EE = dyn_cast<ExtractElementInst>(I)) {
|
} else if (auto *EE = dyn_cast<ExtractElementInst>(I)) {
|
||||||
auto Elements = EE->getOperand(0)->getType()->getVectorNumElements();
|
auto Elements =
|
||||||
|
cast<VectorType>(EE->getOperand(0)->getType())->getNumElements();
|
||||||
auto *O0 = B.CreateZExtOrTrunc(
|
auto *O0 = B.CreateZExtOrTrunc(
|
||||||
EE->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements));
|
EE->getOperand(0), VectorType::get(ScalarTruncatedTy, Elements));
|
||||||
NewI = B.CreateExtractElement(O0, EE->getOperand(2));
|
NewI = B.CreateExtractElement(O0, EE->getOperand(2));
|
||||||
|
@ -285,7 +285,7 @@ static bool isCommutative(Instruction *I) {
|
|||||||
static Optional<TargetTransformInfo::ShuffleKind>
|
static Optional<TargetTransformInfo::ShuffleKind>
|
||||||
isShuffle(ArrayRef<Value *> VL) {
|
isShuffle(ArrayRef<Value *> VL) {
|
||||||
auto *EI0 = cast<ExtractElementInst>(VL[0]);
|
auto *EI0 = cast<ExtractElementInst>(VL[0]);
|
||||||
unsigned Size = EI0->getVectorOperandType()->getVectorNumElements();
|
unsigned Size = EI0->getVectorOperandType()->getNumElements();
|
||||||
Value *Vec1 = nullptr;
|
Value *Vec1 = nullptr;
|
||||||
Value *Vec2 = nullptr;
|
Value *Vec2 = nullptr;
|
||||||
enum ShuffleMode { Unknown, Select, Permute };
|
enum ShuffleMode { Unknown, Select, Permute };
|
||||||
@ -294,7 +294,7 @@ isShuffle(ArrayRef<Value *> VL) {
|
|||||||
auto *EI = cast<ExtractElementInst>(VL[I]);
|
auto *EI = cast<ExtractElementInst>(VL[I]);
|
||||||
auto *Vec = EI->getVectorOperand();
|
auto *Vec = EI->getVectorOperand();
|
||||||
// All vector operands must have the same number of vector elements.
|
// All vector operands must have the same number of vector elements.
|
||||||
if (Vec->getType()->getVectorNumElements() != Size)
|
if (cast<VectorType>(Vec->getType())->getNumElements() != Size)
|
||||||
return None;
|
return None;
|
||||||
auto *Idx = dyn_cast<ConstantInt>(EI->getIndexOperand());
|
auto *Idx = dyn_cast<ConstantInt>(EI->getIndexOperand());
|
||||||
if (!Idx)
|
if (!Idx)
|
||||||
@ -3182,7 +3182,7 @@ bool BoUpSLP::canReuseExtract(ArrayRef<Value *> VL, Value *OpValue,
|
|||||||
if (!LI || !LI->isSimple() || !LI->hasNUses(VL.size()))
|
if (!LI || !LI->isSimple() || !LI->hasNUses(VL.size()))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
NElts = Vec->getType()->getVectorNumElements();
|
NElts = cast<VectorType>(Vec->getType())->getNumElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NElts != VL.size())
|
if (NElts != VL.size())
|
||||||
|
@ -236,10 +236,10 @@ static bool foldExtractExtract(Instruction &I, const TargetTransformInfo &TTI) {
|
|||||||
// ShufMask = { 2, undef, undef, undef }
|
// ShufMask = { 2, undef, undef, undef }
|
||||||
uint64_t SplatIndex = ConvertToShuffle == Ext0 ? C0 : C1;
|
uint64_t SplatIndex = ConvertToShuffle == Ext0 ? C0 : C1;
|
||||||
uint64_t CheapExtIndex = ConvertToShuffle == Ext0 ? C1 : C0;
|
uint64_t CheapExtIndex = ConvertToShuffle == Ext0 ? C1 : C0;
|
||||||
Type *VecTy = V0->getType();
|
auto *VecTy = cast<VectorType>(V0->getType());
|
||||||
Type *I32Ty = IntegerType::getInt32Ty(I.getContext());
|
Type *I32Ty = IntegerType::getInt32Ty(I.getContext());
|
||||||
UndefValue *Undef = UndefValue::get(I32Ty);
|
UndefValue *Undef = UndefValue::get(I32Ty);
|
||||||
SmallVector<Constant *, 32> ShufMask(VecTy->getVectorNumElements(), Undef);
|
SmallVector<Constant *, 32> ShufMask(VecTy->getNumElements(), Undef);
|
||||||
ShufMask[CheapExtIndex] = ConstantInt::get(I32Ty, SplatIndex);
|
ShufMask[CheapExtIndex] = ConstantInt::get(I32Ty, SplatIndex);
|
||||||
IRBuilder<> Builder(ConvertToShuffle);
|
IRBuilder<> Builder(ConvertToShuffle);
|
||||||
|
|
||||||
@ -272,15 +272,14 @@ static bool foldBitcastShuf(Instruction &I, const TargetTransformInfo &TTI) {
|
|||||||
m_Mask(Mask))))))
|
m_Mask(Mask))))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Type *DestTy = I.getType();
|
auto *DestTy = dyn_cast<VectorType>(I.getType());
|
||||||
Type *SrcTy = V->getType();
|
auto *SrcTy = cast<VectorType>(V->getType());
|
||||||
if (!DestTy->isVectorTy() || I.getOperand(0)->getType() != SrcTy)
|
if (!DestTy || I.getOperand(0)->getType() != SrcTy)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO: Handle bitcast from narrow element type to wide element type.
|
// TODO: Handle bitcast from narrow element type to wide element type.
|
||||||
assert(SrcTy->isVectorTy() && "Shuffle of non-vector type?");
|
unsigned DestNumElts = DestTy->getNumElements();
|
||||||
unsigned DestNumElts = DestTy->getVectorNumElements();
|
unsigned SrcNumElts = SrcTy->getNumElements();
|
||||||
unsigned SrcNumElts = SrcTy->getVectorNumElements();
|
|
||||||
if (SrcNumElts > DestNumElts)
|
if (SrcNumElts > DestNumElts)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user