[PATCH] D114542: [CodeGen][SVE] Use whilelo instruction when lowering @llvm.get.active.lane.mask

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 25 01:30:44 PST 2021


SjoerdMeijer added a comment.

In D114542#3153093 <https://reviews.llvm.org/D114542#3153093>, @david-arm wrote:

> Hi @SjoerdMeijer, so after looking into the intrinsic a bit more and talking with @paulwalker-arm, we realised that LoopVectorize.cpp isn't doing any specific overflow checks, which means that when lowering the intrinsic we have to start worrying about overflow. Fortunately for SVE, the `whilelo` instruction actually takes care of overflow already, i.e. there is a 1:1 mapping between the intrinsic and the instruction for many cases. This means that we don't really need to do any of the checks that MVE does for overflow because there is an already efficient way of doing this for SVE. Also, according to the documentation the whilelo instruction takes a start and end value and increments a counter from start to end based on the number of elements requested, i.e. <vscale x 16> elements for a <vscale x 16 x i1> type. So we know exactly which types are safe to map to the instruction and which are not. For some types like <vscale x 32 x i1> (which are illegal and have no mapping) we may also benefit from some of the same checks we do for MVE if we want to improve code quality.

Okay, perhaps I should have been clearer with "overflow checks" and the LoopVectorizer. Basically what I wanted to say is that a vectorized loop/body provides us with a few guarantees, i.e. we know the loop executes at least once, and the loop body processes at least VectorWidth elements. If we could assume this in the MVE lowering pass, then we wouldn't have to do all these overflow and sanity checks. We can't make these assume because the intrinsic could be emitted in the LV, but also somewhere else where we don't have these guarantees.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114542



More information about the llvm-commits mailing list