[PATCH] D78353: [LV] Don't emit the Vector IV if it is not used.

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 03:45:39 PDT 2020


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: Ayal, fhahn, gilr, samparker, dmgreen.
Herald added subscribers: rkruppe, hiraditya.
SjoerdMeijer updated this revision to Diff 258282.

The vector induction variable (IV) is created quite early in the pipeline, but may end not being used, and this change avoids emitting the vector IV if that is the case. The scalar IV is splatted into a vector with a code sequence like this:

  [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 [[INDEX]], i32 0
  [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32>
  [[BROADCAST_SPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer

We save these instructions to a list where they are being created, and remove them at the end in fixVectorizedLoop where similar fixes and clean ups are performed.

The obvious benefit of this simple admin job is that it makes the LV's output more compact and readable, this unused code can be confusing to look at, and other cleanup passes have to work a little bit less hard.


https://reviews.llvm.org/D78353

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
  llvm/test/Transforms/LoopVectorize/AArch64/pr36032.ll
  llvm/test/Transforms/LoopVectorize/ARM/sphinx.ll
  llvm/test/Transforms/LoopVectorize/X86/constant-fold.ll
  llvm/test/Transforms/LoopVectorize/X86/imprecise-through-phis.ll
  llvm/test/Transforms/LoopVectorize/X86/load-deref-pred.ll
  llvm/test/Transforms/LoopVectorize/X86/masked_load_store.ll
  llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll
  llvm/test/Transforms/LoopVectorize/X86/pr35432.ll
  llvm/test/Transforms/LoopVectorize/X86/pr36524.ll
  llvm/test/Transforms/LoopVectorize/X86/strided_load_cost.ll
  llvm/test/Transforms/LoopVectorize/X86/vect.omp.force.small-tc.ll
  llvm/test/Transforms/LoopVectorize/fcmp-vectorize.ll
  llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
  llvm/test/Transforms/LoopVectorize/float-minmax-instruction-flag.ll
  llvm/test/Transforms/LoopVectorize/if-pred-stores.ll
  llvm/test/Transforms/LoopVectorize/multiple-strides-vectorization.ll
  llvm/test/Transforms/LoopVectorize/pr35773.ll
  llvm/test/Transforms/LoopVectorize/pr44488-predication.ll
  llvm/test/Transforms/LoopVectorize/vector-intrinsic-call-cost.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78353.258282.patch
Type: text/x-patch
Size: 74495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200417/0e45952b/attachment-0001.bin>


More information about the llvm-commits mailing list