[llvm] [LV] Change VPVectorPointerRecipe to emit byte GEP instead of typed GEP (PR #174934)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 23:04:24 PST 2026
Mel-Chen wrote:
> > Currently, VPVectorPointerRecipe has the form: vector-pointer %ptr, (%offset).
> > This makes it difficult to add a stride operand to VPVectorPointerRecipe for #147297.
>
> Could you add more detail on what is currently making this difficult?
Sure.
Strided access requires `vector-pointer %base_ptr, %stride`. Assuming we are not considering byte GEPs for now and still use typed GEPs, this recipe will eventually produce
```
gep <EltType> %base_ptr, %VF * part * %stride.
```
After rebasing, #147297 provides a quick and simple approach: changing VPVectorPointerRecipe from
```
vector-pointer %base_ptr, (%offset)
```
to
```
vector-pointer %base_ptr, %stride, (%offset).
```
As I understand it, %offset = %VF * part * %stride. Once %offset is computed after unrolling, there is no need to keep the now-unused %stride. If we want to drop %stride after %offset is available, operand 1 of VPVectorPointerRecipe could end up being either %stride or %offset, i.e.
vector-pointer %base_ptr, %stride | %offset.
This would likely require adding a `bool isUnrolled` to distinguish which field it represents, but I don’t think that’s a good approach.
Another direction would be to rename offset (I don’t have a good name yet, so let’s call it VFxPart for now). Initially, we would only create
```
vector-pointer %base_ptr, %stride
```
and during unrolling change it to
```
vector-pointer %base_ptr, %stride, %VFxPart
```
Then, in `VPVectorPointerRecipe::execute`, we would compute
`gep <EltType> %base_ptr, %VFxPart * %stride`.
Which approach to take depends on whether we want all Mul operations of VPVectorPointerRecipe to be explicitly represented as recipes in VPlan.
https://github.com/llvm/llvm-project/pull/174934
More information about the llvm-commits
mailing list