[PATCH] D30200: [SLP] Fix for PR31880: shuffle and vectorize repeated scalar ops on extracted elements

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 07:19:04 PST 2017


ABataev created this revision.

Currently most of the time vectors of extractelement instructions are
treated as scalars that must be gathered into vectors. But in some
cases, like when we have extractelement instructions from single vector
with different constant indeces or from 2 vectors of the same size, we
can treat this operations as shuffle of a single vector or blending of 2
vectors.

  define <2 x i8> @g(<2 x i8> %x, <2 x i8> %y) {
    %x0 = extractelement <2 x i8> %x, i32 0
    %y1 = extractelement <2 x i8> %y, i32 1
    %x0x0 = mul i8 %x0, %x0
    %y1y1 = mul i8 %y1, %y1
    %ins1 = insertelement <2 x i8> undef, i8 %x0x0, i32 0
    %ins2 = insertelement <2 x i8> %ins1, i8 %y1y1, i32 1
    ret <2 x i8> %ins2
  }

can be converted to something like

  define <2 x i8> @g(<2 x i8> %x, <2 x i8> %y) {
    %1 = shufflevector <2 x i8> %x, <2 x i8> %y, <2 x i32> <i32 0, i32 3>
    %2 = mul <2 x i8> %1, %1
    ret <2 x i8> %2
  }

Currently this type of conversion is considered as high cost
transformation.


https://reviews.llvm.org/D30200

Files:
  lib/Transforms/Vectorize/SLPVectorizer.cpp
  test/Transforms/SLPVectorizer/X86/blending-shuffle.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30200.89208.patch
Type: text/x-patch
Size: 14846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170221/230a332a/attachment.bin>


More information about the llvm-commits mailing list