[llvm] 8e204f8 - [SVE] Generalize size checks in Verifier to use getElementCount
Christopher Tetreault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 16 16:03:52 PDT 2020
Author: Christopher Tetreault
Date: 2020-06-16T16:03:36-07:00
New Revision: 8e204f807b9df3c0a6fd14fcb038a46591b23f0b
URL: https://github.com/llvm/llvm-project/commit/8e204f807b9df3c0a6fd14fcb038a46591b23f0b
DIFF: https://github.com/llvm/llvm-project/commit/8e204f807b9df3c0a6fd14fcb038a46591b23f0b.diff
LOG: [SVE] Generalize size checks in Verifier to use getElementCount
Summary:
Attempts to call getNumElements on scalable vectors identified by test
LLVM.Other::scalable-vectors-core-ir.ll. Since these checks are all
attempting to find if two vectors are the same size, calling
getElementCount will only increase safety.
Reviewers: efriedma, aprantl, reames, kmclaughlin, sdesmalen
Reviewed By: efriedma
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81895
Added:
Modified:
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index f1dc4b725ea1..0ca200cd950a 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2743,8 +2743,8 @@ void Verifier::visitUIToFPInst(UIToFPInst &I) {
&I);
if (SrcVec && DstVec)
- Assert(cast<VectorType>(SrcTy)->getNumElements() ==
- cast<VectorType>(DestTy)->getNumElements(),
+ Assert(cast<VectorType>(SrcTy)->getElementCount() ==
+ cast<VectorType>(DestTy)->getElementCount(),
"UIToFP source and dest vector length mismatch", &I);
visitInstruction(I);
@@ -2766,8 +2766,8 @@ void Verifier::visitSIToFPInst(SIToFPInst &I) {
&I);
if (SrcVec && DstVec)
- Assert(cast<VectorType>(SrcTy)->getNumElements() ==
- cast<VectorType>(DestTy)->getNumElements(),
+ Assert(cast<VectorType>(SrcTy)->getElementCount() ==
+ cast<VectorType>(DestTy)->getElementCount(),
"SIToFP source and dest vector length mismatch", &I);
visitInstruction(I);
@@ -2789,8 +2789,8 @@ void Verifier::visitFPToUIInst(FPToUIInst &I) {
"FPToUI result must be integer or integer vector", &I);
if (SrcVec && DstVec)
- Assert(cast<VectorType>(SrcTy)->getNumElements() ==
- cast<VectorType>(DestTy)->getNumElements(),
+ Assert(cast<VectorType>(SrcTy)->getElementCount() ==
+ cast<VectorType>(DestTy)->getElementCount(),
"FPToUI source and dest vector length mismatch", &I);
visitInstruction(I);
@@ -2812,8 +2812,8 @@ void Verifier::visitFPToSIInst(FPToSIInst &I) {
"FPToSI result must be integer or integer vector", &I);
if (SrcVec && DstVec)
- Assert(cast<VectorType>(SrcTy)->getNumElements() ==
- cast<VectorType>(DestTy)->getNumElements(),
+ Assert(cast<VectorType>(SrcTy)->getElementCount() ==
+ cast<VectorType>(DestTy)->getElementCount(),
"FPToSI source and dest vector length mismatch", &I);
visitInstruction(I);
@@ -2835,9 +2835,9 @@ void Verifier::visitPtrToIntInst(PtrToIntInst &I) {
&I);
if (SrcTy->isVectorTy()) {
- VectorType *VSrc = cast<VectorType>(SrcTy);
- VectorType *VDest = cast<VectorType>(DestTy);
- Assert(VSrc->getNumElements() == VDest->getNumElements(),
+ auto *VSrc = cast<VectorType>(SrcTy);
+ auto *VDest = cast<VectorType>(DestTy);
+ Assert(VSrc->getElementCount() == VDest->getElementCount(),
"PtrToInt Vector width mismatch", &I);
}
@@ -2860,9 +2860,9 @@ void Verifier::visitIntToPtrInst(IntToPtrInst &I) {
Assert(SrcTy->isVectorTy() == DestTy->isVectorTy(), "IntToPtr type mismatch",
&I);
if (SrcTy->isVectorTy()) {
- VectorType *VSrc = cast<VectorType>(SrcTy);
- VectorType *VDest = cast<VectorType>(DestTy);
- Assert(VSrc->getNumElements() == VDest->getNumElements(),
+ auto *VSrc = cast<VectorType>(SrcTy);
+ auto *VDest = cast<VectorType>(DestTy);
+ Assert(VSrc->getElementCount() == VDest->getElementCount(),
"IntToPtr Vector width mismatch", &I);
}
visitInstruction(I);
More information about the llvm-commits
mailing list