[PATCH] D50778: [LV] Vectorize loops where non-phi instructions used outside loop

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 15 15:15:50 PDT 2018


Ayal added a comment.

Suggest to update `InnerLoopVectorizer::fixLCSSAPHIs()` as follows, now that arbitrary values are allowed to be live-out:

  unsigned LastLane = Cost->isUniformAfterVectorization(IncomingValue, VF) ? 0 : VF - 1;
  Value *lastIncomingValue =
      getOrCreateScalarValue(IncomingValue, {UF - 1, LastLane});



================
Comment at: lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:582
 
+  bool PredicateValidOutsideLoop = PSE.getUnionPredicate().isAlwaysTrue();
+
----------------
Use `PredicateValidOutsideLoop` below?


================
Comment at: lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:728
+          continue;
+        }
         ORE->emit(createMissedAnalysis("ValueUsedOutsideLoop", &I)
----------------
It would now be good to reason about and mark all exits that are **not allowed** to be live-out, rather than those that are :-). Specifically, Reduction Phi's are on this "not allowed" list, as they represent the one-before-last value, which is not available when vectorized (could possibly be computed by "subtracting" from the final reduced value), unlike the Reduction bump instructions. Induction Phi's and their bumps are, as pointed out here, also on this "not allowed" list when the SCEV predicates cannot be used outside the loop, because the latter are used to pre-compute the live-out values. But such cases could possibly be handled alternatively by extracting from within the loop, similar to internal Instructions, rather than pre-computing. FirstOrderRecurrence Phi's are also currently one the "not allowed" list, unlike their "Previous" value, and could also possibly be handled using extraction. Would be good to confirm that this enumeration is exhaustive.


Repository:
  rL LLVM

https://reviews.llvm.org/D50778





More information about the llvm-commits mailing list