[llvm] [CodeGen] Implement widening for partial.reduce.add (PR #161834)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 10 09:47:24 PDT 2025


paulwalker-arm wrote:

I've only partially (pun intended) reviewed the patch because several of the new asserts look more like hope than expectation? so I'm wondering if it would be better to first implement widening that works in all cases and then add more optimal handling for the special cases you care about?  For general widening I think something like the follow can work:
```
WidenACC = insert_subvector(get_poison(WideVT), Acc, 0)
WidenMul = insert_element(zero(WideVT), vec_add_reduce(mul(extend(MulOp1), extend(MulOp2))), 0)
return add(WidenACC, WidenMul)
```
This will move all the complication relating to having compatible operand types to the special cases where you can turn the asserts into requirements.  An alternative to the above is to reduce the accumulator instead:
```
NewACC = insert_element(get_posion(1 x ty), vec_add_reduce(ACC))
return insert_subvector(get_poison(WideVT), get_partial_reduce(NewACC, MulOp1, MulOp2), 0)
```
This seems simpler and keeps the implicit extension for the mul operands. The chances are the first version will then be necessary for WidenVecOp_PARTIAL_REDUCE_MLA, but I think that will always be the case so it just depends on which looks cleaner once all the bases are covered.

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


More information about the llvm-commits mailing list