[PATCH] D79100: [LV][TTI] Emit new IR intrinsic llvm.get.active.mask for tail-folded loops

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 25 19:19:40 PDT 2020


efriedma added a comment.

> The intrinsic now takes two scalar arguments, the first element of the VIV, and the scalar BTC, hopefully in the way you head in mind.

Yes, this is what I expected.

> On the dev list, Ayal pointed out an alternative to rediscover the BTC in the backend (still need spend time to confirm we then don't miss anything). This intrinsic still would have my preference because of its convenience, and as it a general concept it seems to support different uses too (vp intrinsicss, and provides a target independent way of describing the active mask).

In general, given two expressions that are equivalent, there's always some way to pattern-match. For power-of-two fixed-width vectors, the pattern you'd need to match is not that complicated (basically just an icmp where one operand is a vector induction variable, and the other operand is a splat.) But like you say, the intrinsic is more convenient.

If you're dealing with scalable vectors, expanding the intrinsic to arithmetic would result in a very complex expression due to the potential for overflow, so we'll almost certainly want this intrinsic.

----

The changes to VPlan.cpp look a little suspicious, but I'm not really familiar with that code, so I'll let someone else review it.



================
Comment at: llvm/docs/LangRef.rst:16202
+`icmp ule %VIV, (splat %BTC)`, where VIV is the Vector Induction Variable, and
+BTC the back-edge taken count splat into a vector. Thus, these intrinsics
+perform an element-wise less than or equal comparison of VIV with BTC,
----------------
Maybe qualify this with the caveat that it's only equivalent if the vector induction variable doesn't overflow.  We probably want to return false in the lanes where it overflows.


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

https://reviews.llvm.org/D79100





More information about the llvm-commits mailing list