[llvm] [LangRef] Cap maximum value of vscale at 2^31-1. (PR #144607)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 03:59:42 PDT 2025


https://github.com/fhahn commented:

> > > I'm sure restricting the range of vscale will have other benefits but that feels like an independent change and we already have mechanisms to achieve this via vscale_range (and range?) attributes.
> > 
> > 
> > I think this is a case of false generality. We could explore alternate options here, but this patch has the major advantage of being _simple_. We can come back and revisit this (even reverse it) if needed, but I see no reason not to go with the simple answer for the moment.
> 
> I'm not suggesting we do any work, only that the restriction should be specified in terms of the runtime vector length and not about `vscale`. I think this would actually be less work and easier to walk back because with the current `vscale` suggestion the next obvious step is to update `getVScaleRange()` to implement the new requirement, whereas with my suggestion there's no change to any part of the IR.
> 


Currently the number of vector elements can be at most 2^32-1 (https://llvm.godbolt.org/z/saes7j5zf), although I don't think it is currently spelled out in LangRef.

Are you thinking along the lines of spelling out that the runtime VF is required to be at most 2^32-1. But that definition could also be derive a limit for `vscale` in a similar way?

I am not sure if the definition in terms of runtime VF would be useful when creating new vector types, as we don't know if new scalable vector type we are creating satisfy the property that the runtime VF < 2^32 and the new types still may violate it?

> > > I'm sure restricting the range of vscale will have other benefits but that feels like an independent change and we already have mechanisms to achieve this via vscale_range (and range?) attributes.

We could exclusively rely on `vscale_range`, but then we would probably need to emit an extra runtime check if it is not present, to check if the new runtime VF is < 2^32?

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


More information about the llvm-commits mailing list