[PATCH] D23889: [LV] Scalarize instructions marked scalar after vectorization

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 12:15:35 PDT 2016


mssimpso created this revision.
mssimpso added reviewers: samparker, anemet, mkuper, wmi.
mssimpso added subscribers: llvm-commits, mcrosier.
Herald added subscribers: nemanjai, mzolotukhin.

This patch ensures that we actually scalarize instructions marked scalar after vectorization. In order to prevent an increase in code size, we optimize the scalarization of instructions that are also marked uniform after vectorization. When scalarizing uniforms, we only need to generate one scalar value for each unroll iteration, rather than VF values per iteration.

For this to work properly, we need to be more careful about the instructions we mark uniform. If we mark something uniform, but it's actually only scalar, we won't generate the needed scalar values for it with the above change.

Consecutive GEPs are a problem area. Without the changes in this patch, we mark all consecutive GEPs uniform. However, if the GEP is used by a memory instruction that is eventually scalarized, it won't remain uniform after all. An example is predicated stores. Even though a predicated store may be consecutive, it will still be scalarized, making it's pointer operand non-uniform. We actually need to consider all the scalarization conditions in vectorizeMemoryInstruction when deciding if a pointer operand is uniform. This patch makes the logic in collectLoopUniforms involving consecutive pointers a little more conservative.

https://reviews.llvm.org/D23889

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/PowerPC/small-loop-rdx.ll
  test/Transforms/LoopVectorize/PowerPC/vsx-tsvc-s173.ll
  test/Transforms/LoopVectorize/global_alias.ll
  test/Transforms/LoopVectorize/induction.ll
  test/Transforms/LoopVectorize/induction_plus.ll
  test/Transforms/LoopVectorize/reverse_induction.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23889.69280.patch
Type: text/x-patch
Size: 15916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160825/f741a82f/attachment.bin>


More information about the llvm-commits mailing list