[PATCH] D81969: [SVE] Fix invalid usages of getNumElements in ShuffleVectorInstruction

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 14:02:52 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b776a98f1a4: [SVE] Fix invalid usages of getNumElements in ShuffleVectorInstruction (authored by ctetreau).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81969/new/

https://reviews.llvm.org/D81969

Files:
  llvm/include/llvm/IR/Instructions.h
  llvm/lib/IR/Instructions.cpp


Index: llvm/lib/IR/Instructions.cpp
===================================================================
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -2205,8 +2205,14 @@
 bool ShuffleVectorInst::isIdentityWithExtract() const {
   if (isa<UndefValue>(Op<2>()))
     return false;
-  int NumOpElts = cast<VectorType>(Op<0>()->getType())->getNumElements();
-  int NumMaskElts = getType()->getNumElements();
+
+  // FIXME: Not currently possible to express a shuffle mask for a scalable
+  // vector for this case
+  if (isa<ScalableVectorType>(getType()))
+    return false;
+
+  int NumOpElts = cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
+  int NumMaskElts = cast<FixedVectorType>(getType())->getNumElements();
   if (NumMaskElts >= NumOpElts)
     return false;
 
Index: llvm/include/llvm/IR/Instructions.h
===================================================================
--- llvm/include/llvm/IR/Instructions.h
+++ llvm/include/llvm/IR/Instructions.h
@@ -1977,7 +1977,7 @@
   ///           shufflevector <4 x n> A, <4 x n> B, <1,2,3,4,5>
   bool changesLength() const {
     unsigned NumSourceElts =
-        cast<VectorType>(Op<0>()->getType())->getNumElements();
+        cast<VectorType>(Op<0>()->getType())->getElementCount().Min;
     unsigned NumMaskElts = ShuffleMask.size();
     return NumSourceElts != NumMaskElts;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81969.271476.patch
Type: text/x-patch
Size: 1374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200617/eaf384fc/attachment.bin>


More information about the llvm-commits mailing list