[PATCH] D79175: [ARM][MVE] Tail-Predication: use @llvm.get.active.lane.mask to get the BTC
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 13:28:09 PDT 2020
efriedma 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");
----------------
SjoerdMeijer wrote:
> 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).
The description of isKnownNegativeInLoop says "Returns true if we can prove that \p S is defined and always negative in loop L." If it returns false, we have proven nothing, so you can't use it like this.
I wasn't trying to imply you shouldn't use isKnownNonNegativeInLoop, if that's appropriate.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79175/new/
https://reviews.llvm.org/D79175
More information about the llvm-commits
mailing list