[PATCH] D25632: [LV] Sink scalar operands of predicated instructions

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 12:17:29 PDT 2016


mssimpso created this revision.
mssimpso added reviewers: anemet, mkuper, gilr.
mssimpso added subscribers: llvm-commits, mcrosier.
Herald added a subscriber: mzolotukhin.

When we predicate an instruction (div, rem, store) we place the instruction in its own basic block within the vectorized loop. If a predicated instruction has scalar operands, it's possible to recursively sink these scalar expressions into the predicated block so that they might avoid execution. This patch sinks as much scalar computation as possible into predicated blocks. We previously were able to sink such operands only if they were extractelement instructions.

For example, if we have a predicated store "a[i] = x", instead of generating:

  vector.body:
    ...
    %i = add i64 %index, 1
    %p = getelementptr inbounds i32, i32* %a, i64 %i
    %x = extractelement <2 x i32> %vec, i32 0
    ...
  pred.store:
    store i32 %x, i32* %p
    ...

We will now generate:

  vector.body:
    ...
  pred.store:
    %i = add i64 %index, 1
    %p = getelementptr inbounds i32, i32* %a, i64 %i
    %x = extractelement <2 x i32> %vec, i32 0
    store i32 %x, i32* %p
    ...


https://reviews.llvm.org/D25632

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/consecutive-ptr-uniforms.ll
  test/Transforms/LoopVectorize/if-pred-non-void.ll
  test/Transforms/LoopVectorize/if-pred-stores.ll
  test/Transforms/LoopVectorize/induction.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25632.74728.patch
Type: text/x-patch
Size: 14333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161014/bf820e54/attachment.bin>


More information about the llvm-commits mailing list