[PATCH] D79175: [ARM][MVE] Tail-Predication: use @llvm.get.active.lane.mask to get the BTC

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 12:22:57 PDT 2020


SjoerdMeijer marked an inline comment as done.
SjoerdMeijer added inline comments.


================
Comment at: llvm/lib/Target/ARM/MVETailPredication.cpp:384
+  // Evaluate this and bail if it can be negative.
+  if (llvm::isKnownNegativeInLoop(ECMinusTC, L, *SE)) {
+    LLVM_DEBUG(dbgs() << "ARM TP: overflow in element count decrement\n");
----------------
efriedma wrote:
> !isKnownNonNegative?
I played with SCEV today, and tried to use `isKnownNonNegative` (and similar ones). These SCEV helpers don't seem to provide the required information, i.e. they are not able to find precise enough value ranges to tell us values are non-negative, and so the `isKnownNonNegative` SCEV helpers and friends don't seem to have the context of the loop. Our loops usually look like this, they have this or a similar loop guard:

    %cmp = icmp sgt %N, 0
    br i1 %cmp, label %vector.preheader, label %exit

For this example, %N is our ElementCount. When we construct our overflow check:

    ceil(ElementCount / VectorWidth) >= TripCount

and query SCEV, it doesn't have the context that %N > 0, resulting in a negative lowerbound, and thus `isKnownNonNegative` returns False. Looking into how I could add more context to SCEV, I checked for example `getSCEVAtScope` hoping this would be more context sensitive, and some others too. PredicatedScalarEvolution looked promising, I think it is designed for exactly this (I haven't used  it yet), but the LoopUtils helpers `isKnownNegativeInLoop` and `cannotBeMaxInLoop` provide this with a convenience interface. These LoopUtils helpers were actually contributed by @samparker after a similar experience (which he might be able to confirm here).

Long story short, it looks like  helpers `isKnownNegativeInLoop` and `cannotBeMaxInLoop` are actually the right choice here (also confirmed after further debugging and tracing the tests that I mentioned previously).


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

https://reviews.llvm.org/D79175





More information about the llvm-commits mailing list