[llvm] 3b7f3d0 - [SVE] Remove invalid usage of getNumElements in Instructions

Christopher Tetreault via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 08:37:05 PDT 2020


Author: Christopher Tetreault
Date: 2020-05-04T08:36:37-07:00
New Revision: 3b7f3d012bcdabf9314d0d3f4744c7594bfa55a7

URL: https://github.com/llvm/llvm-project/commit/3b7f3d012bcdabf9314d0d3f4744c7594bfa55a7
DIFF: https://github.com/llvm/llvm-project/commit/3b7f3d012bcdabf9314d0d3f4744c7594bfa55a7.diff

LOG: [SVE] Remove invalid usage of getNumElements in Instructions

Summary:
Remove invalid usage of VectorType::getNumElements in
ShuffleVectorInst::isValidOperands identified by test case
llvm::Analysis/ConstantFolding/vscale-shufflevector.ll. The tested
conditions hold for both fixed width and scalable vectors; use
getElementCount().

Reviewers: efriedma, sdesmalen, c-rhodes, spatel

Reviewed By: sdesmalen

Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79212

Added: 
    

Modified: 
    llvm/lib/IR/Instructions.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index cccbd512204e..d9cda0f7de1f 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -1916,11 +1916,11 @@ void ShuffleVectorInst::commute() {
 bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
                                         ArrayRef<int> Mask) {
   // V1 and V2 must be vectors of the same type.
-  if (!V1->getType()->isVectorTy() || V1->getType() != V2->getType())
+  if (!isa<VectorType>(V1->getType()) || V1->getType() != V2->getType())
     return false;
 
   // Make sure the mask elements make sense.
-  int V1Size = cast<VectorType>(V1->getType())->getNumElements();
+  int V1Size = cast<VectorType>(V1->getType())->getElementCount().Min;
   for (int Elem : Mask)
     if (Elem != UndefMaskElem && Elem >= V1Size * 2)
       return false;


        


More information about the llvm-commits mailing list