[PATCH] D113394: [IR] In ConstantFoldShuffleVectorInstruction use zeroinitializer for splats of 0

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 8 05:25:58 PST 2021


david-arm created this revision.
david-arm added reviewers: sdesmalen, kmclaughlin, c-rhodes, ThomasRaoux, efriedma.
Herald added subscribers: dexonsmith, hiraditya.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When creating a splat of 0 for scalable vectors we tend to create them
with using a combination of shufflevector and insertelement, i.e.

shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 0, i32 0),

  <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer)

However, for the case of a zero splat we can actually just replace the
above with zeroinitializer instead. This makes the IR a lot simpler and
easier to read. I have changed ConstantFoldShuffleVectorInstruction to
use zeroinitializer when creating a splat of integer 0 or FP +0.0 values.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113394

Files:
  llvm/lib/IR/ConstantFold.cpp
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-strict-fadd.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-basic-vec.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-select-cmp.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-gep.ll
  llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
  llvm/test/Transforms/LoopVectorize/scalable-reduction-inloop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113394.385462.patch
Type: text/x-patch
Size: 18731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211108/8a343b11/attachment.bin>


More information about the llvm-commits mailing list