================
@@ -554,6 +554,22 @@ class VectorType : public Type {
     return VectorType::get(VTy->getElementType(), EltCnt * 2);
   }
 
+  /// This static method returns a VectorType with the same size-in-bits as
+  /// SizeTy but with an element type that matches the scalar type of EltTy.
+  static VectorType *getWithSizeAndScalar(VectorType *SizeTy, Type *EltTy) {
+    if (SizeTy->getScalarType() == EltTy->getScalarType())
+      return SizeTy;
+
+    unsigned EltSize = EltTy->getScalarSizeInBits();
+    if (!SizeTy->getPrimitiveSizeInBits().isKnownMultipleOf(EltSize))
----------------
paulwalker-arm wrote:

Are you sure? The intent of this function is to create a VectorType that can be 
bitcasted, typically from/to `SizeTy`. When looking at 
`CastInst::castIsValid()` I can see it uses `getPrimitiveSizeInBits()` to 
determine validity.

To put another way, the check is ensuring the IR is consistent, essentially 
protecting against the case where the ElementCount calculation would be 
invalid. So I don't think this function cares about data layout?


https://github.com/llvm/llvm-project/pull/130973
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to