[PATCH] D104308: [VP] Add vector-predicated reduction intrinsics

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 21 06:17:53 PDT 2021


frasercrmck added a comment.

In D104308#2830045 <https://reviews.llvm.org/D104308#2830045>, @simoll wrote:

> Disabling lanes is really what makes the difference between these and the regular reduction intrinsics.
> There is also the corner case that all lanes are disabled and i am unsure what the return value should be then. Any thoughts on that?

Agreed. I'll update the docs accordingly.

We have a couple of options for what happens when all lanes are disabled. For starters, it follows logically from the definition of the expansion into `reduce(select %mask, %v, %neutral)` that we just return the neutral element. So that's the "easiest" definition in that sense.

We could return `undef` too which would be closer to how the other VP intrinsics work.

As for other options, it wouldn't make sense to me to specify that we return any of the vector elements (e.g. `v[0]`) as they're not conceptually active. And I think `poison` wouldn't make any sense. Are those the only realistic options?

In terms of hardware (which is orthogonal but may help guide us), RVV always takes a start value so we'd just return the neutral element; I admit I might be surreptitiously led by that. The lowering for returning the "neutral element" may be complicated on some targets, involving fetching the active length and perhaps doing some kind of scalar select. How would VE work?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104308/new/

https://reviews.llvm.org/D104308



More information about the llvm-commits mailing list