[PATCH] D16197: [LV] Vectorize first-order recurrences

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 10:45:38 PST 2016


mssimpso added inline comments.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3573-3585
@@ +3572,15 @@
+
+  // Get the initial and previous values of the scalar recurrence. First-order
+  // recurrences are of the form "current = phi(initial, previous)".
+  auto *ScalarInit = Phi->getIncomingValue(0);
+  auto *Previous = Phi->getIncomingValue(1);
+  if (!OrigLoop->isLoopInvariant(ScalarInit))
+    std::swap(ScalarInit, Previous);
+
+  // Ensure the previous value is loop-varying and the initial value is
+  // loop-invariant.
+  assert(!OrigLoop->isLoopInvariant(Previous) &&
+         "Previous value is loop-varying");
+  assert(OrigLoop->isLoopInvariant(ScalarInit) &&
+         "Initial value isn't loop-invariant");
+
----------------
anemet wrote:
> mssimpso wrote:
> > anemet wrote:
> > > This is duplicated between here and isFirstOrderRecurrence, would be nice to somehow remove this.
> > Sure, I will delete these assertions here.
> I didn't mean this only for the asserts.  I think it would make sense to factor out the way we get the previous and init for a first-order recurrence somewhere (e.g. RecurrenceDescriptor?).
> 
> There may also be some common functionality between this new function and RecurrenceDescriptor::isFirstOrderRecurrence that could be shared.
> 
I see. Thanks for clarifying!


http://reviews.llvm.org/D16197





More information about the llvm-commits mailing list