[PATCH] D31979: [LV] Fix the vector code generation for first order recurrence

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 08:00:09 PDT 2017


anna added a comment.

Hi Matt,

Just FYI: The logic differs slightly from what you suggested in https://reviews.llvm.org/D31910#723721.
We need to extract from the correct index of the vectorized phi update. Extracting from index 3 of the vectorized phi (`vector.recur`), will give you the element at `vector.update(3) - VF`, which won't work.

  middle.block:
    %vector.recur.extract = extractelement <4 x i32> %vector.update, i32 3
    %new.extract = extractelement <4 x i32> %vector.recur, i32 3

What we need is the the vectorized loop element equivalent to the second last element in the scalar loop (since the phi is the second last and the phi update is the last).

So, the logic used in this patch is:

  middle.block:
    %vector.recur.extract = extractelement <4 x i32> %vector.update, i32 3
    %vector.recur.extract.for.phi = extractelement <4 x i32> %vector.update, i32 2
  scalar.ph:
    %scalar.recur.init = phi i32 [ %vector.recur.extract, %middle.block ], ...
  for.end:
    %r.lcssa = phi i32 [ %scalar.recur, %for.body ], [ %vector.recur.extract.for.phi, %middle.block ]


https://reviews.llvm.org/D31979





More information about the llvm-commits mailing list