[PATCH] D22416: [LV] Move vector induction update to end of latch

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 10:56:33 PDT 2016


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

This patch moves the update instruction for vectorized integer induction phi nodes to the end of the latch block. This ensures consistent placement of all induction updates despite the kind of induction we create (scalar, splat vector, or vector phi).

Brief background:

I was comparing the IR, post-instcombine, we generate using the vector splat and vector phi methods of widening induction variables. The vector splat method keeps the original update we create at the end of the latch:

```
i = phi [0, pre-header], [i.next, latch]
...
i.next = i + 1 
cmp i.next
br
```

whereas the vector phi method was generating code that simplifies to: 

```
i = phi [0, pre-header], [i.next, latch]
i.next = i + 1 
...
cmp i.next
br
```

with the update at the top of the header. This is because the original scalar update was being replaced by the new update during simplification. This is not a huge deal, but this patch ensures that for many cases, both methods can simplify to the same IR. 

Let me know what you think.

https://reviews.llvm.org/D22416

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/X86/scatter_crash.ll
  test/Transforms/LoopVectorize/induction.ll
  test/Transforms/LoopVectorize/induction_plus.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22416.64166.patch
Type: text/x-patch
Size: 8187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160715/e93de2df/attachment.bin>


More information about the llvm-commits mailing list