[llvm] 19cc9b9 - Clean up usages of asserting vector getters in Type
Christopher Tetreault via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 14:59:31 PDT 2020
Author: Christopher Tetreault
Date: 2020-04-09T14:59:14-07:00
New Revision: 19cc9b9ded9b5f43dcb10335165499058b122c10
URL: https://github.com/llvm/llvm-project/commit/19cc9b9ded9b5f43dcb10335165499058b122c10
DIFF: https://github.com/llvm/llvm-project/commit/19cc9b9ded9b5f43dcb10335165499058b122c10.diff
LOG: 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: efriedma, sdesmalen, rriddle
Reviewed By: sdesmalen
Subscribers: hiraditya, dantrushin, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77261
Added:
Modified:
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Scalar/Scalarizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index b8b98d673334..e4bc345819b1 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2630,10 +2630,9 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F, DominatorTree &DT,
unsigned VF = 0;
for (unsigned i = 0; i < I.getNumOperands(); i++)
- if (I.getOperand(i)->getType()->isVectorTy()) {
- assert(VF == 0 ||
- VF == I.getOperand(i)->getType()->getVectorNumElements());
- VF = I.getOperand(i)->getType()->getVectorNumElements();
+ if (auto *OpndVTy = dyn_cast<VectorType>(I.getOperand(i)->getType())) {
+ assert(VF == 0 || VF == OpndVTy->getNumElements());
+ VF = OpndVTy->getNumElements();
}
// It's the vector to scalar traversal through the pointer operand which
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index dc64287550d3..8404188a951b 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -252,7 +252,7 @@ Scatterer::Scatterer(BasicBlock *bb, BasicBlock::iterator bbi, Value *v,
PtrTy = dyn_cast<PointerType>(Ty);
if (PtrTy)
Ty = PtrTy->getElementType();
- Size = Ty->getVectorNumElements();
+ Size = cast<VectorType>(Ty)->getNumElements();
if (!CachePtr)
Tmp.resize(Size, nullptr);
else if (CachePtr->empty())
@@ -269,7 +269,7 @@ Value *Scatterer::operator[](unsigned I) {
return CV[I];
IRBuilder<> Builder(BB, BBI);
if (PtrTy) {
- Type *ElTy = PtrTy->getElementType()->getVectorElementType();
+ Type *ElTy = cast<VectorType>(PtrTy->getElementType())->getElementType();
if (!CV[0]) {
Type *NewPtrTy = PointerType::get(ElTy, PtrTy->getAddressSpace());
CV[0] = Builder.CreateBitCast(V, NewPtrTy, V->getName() + ".i0");
@@ -852,10 +852,10 @@ bool ScalarizerVisitor::finish() {
if (!Op->use_empty()) {
// The value is still needed, so recreate it using a series of
// InsertElements.
- Type *Ty = Op->getType();
+ auto *Ty = cast<VectorType>(Op->getType());
Value *Res = UndefValue::get(Ty);
BasicBlock *BB = Op->getParent();
- unsigned Count = Ty->getVectorNumElements();
+ unsigned Count = Ty->getNumElements();
IRBuilder<> Builder(Op);
if (isa<PHINode>(Op))
Builder.SetInsertPoint(BB, BB->getFirstInsertionPt());
More information about the llvm-commits
mailing list