[PATCH] D72792: [SVE] Pass Scalable argument to VectorType::get in Bitcode Reader

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 10:50:25 PST 2020


ctetreau created this revision.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.

- Pass the Scalability test to VectorType::get in order to be

able to deserialize bitcode that contains scalable vector operations

Change-Id: I37fe5b1c0c237a9153130deefdc1a6d595c7f12e


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72792

Files:
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp


Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2629,12 +2629,14 @@
 
       Type *SelectorTy = Type::getInt1Ty(Context);
 
-      // The selector might be an i1 or an <n x i1>
+      // The selector might be an i1, an <n x i1>, or a <vscale x n x i1>
       // Get the type from the ValueList before getting a forward ref.
       if (VectorType *VTy = dyn_cast<VectorType>(CurTy))
         if (Value *V = ValueList[Record[0]])
           if (SelectorTy != V->getType())
-            SelectorTy = VectorType::get(SelectorTy, VTy->getNumElements());
+            SelectorTy = VectorType::get(SelectorTy,
+                                         VTy->getNumElements(),
+                                         VTy->isScalable());
 
       V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
                                                               SelectorTy),
@@ -2692,7 +2694,8 @@
       Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
       Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
       Type *ShufTy = VectorType::get(Type::getInt32Ty(Context),
-                                                 OpTy->getNumElements());
+                                     OpTy->getNumElements(),
+                                     OpTy->isScalable());
       Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy);
       V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
       break;
@@ -2706,7 +2709,8 @@
       Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
       Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
       Type *ShufTy = VectorType::get(Type::getInt32Ty(Context),
-                                                 RTy->getNumElements());
+                                     RTy->getNumElements(),
+                                     RTy->isScalable());
       Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy);
       V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
       break;
@@ -4167,9 +4171,15 @@
         return error("Invalid record");
       if (!Vec1->getType()->isVectorTy() || !Vec2->getType()->isVectorTy())
         return error("Invalid type for value");
+
+      bool Vec1IsScalable = cast<VectorType>(Vec1->getType())->isScalable();
+      if (Vec1IsScalable != cast<VectorType>(Vec2->getType())->isScalable())
+        return error("Vector Scalability mismatch between types");
+
       I = new ShuffleVectorInst(Vec1, Vec2, Mask);
       FullTy = VectorType::get(FullTy->getVectorElementType(),
-                               Mask->getType()->getVectorNumElements());
+                               Mask->getType()->getVectorNumElements(),
+                               Vec1IsScalable);
       InstructionList.push_back(I);
       break;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72792.238320.patch
Type: text/x-patch
Size: 2960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200115/e02c50d1/attachment.bin>


More information about the llvm-commits mailing list