[clang] [llvm] [LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. (PR #130973)

Paul Walker via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 10 10:34:44 PDT 2025


================
@@ -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) {
----------------
paulwalker-arm wrote:

I really struggled to come up with a name that conveyed enough information whilst not causing all uses to overflow the 80 char line limit. This attempt being a shortened version of `get[VectorType]With[Total]Size[of_the_first_operand]AndScalar[Type_of_the second_operand]`. I'm not precious over this so suggestions are very welcome.

The downside of passing in a `TypeSize` is that I'd always have to create a new VectorType, whereas the current implementation has an early exit for the most common case of "casting" between fixed and scalable vectors of the same element type.

A lesser reason was it being awkward to convert between ElementCount and TypeSize and I wanted to avoid introducing another use of `getKnownMinValue()`.

Is this rational strong enough? or would you rather I go the `TypeSize` route?

https://github.com/llvm/llvm-project/pull/130973


More information about the cfe-commits mailing list