[PATCH] D46101: [PowerPC] vectorize Sum of Absolute Difference

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 25 19:52:27 PDT 2018


inouehrs created this revision.
inouehrs added reviewers: hfinkel, echristo, craig.topper, kbarton, nemanjai, sfertile, lei, syzaara.

This patch enables vectorization of Sum of Absolute Difference (SAD), which is already supported in x86 backend.
For example, the following code is compiled with vector max/min and sum-across instructions.

  uint8_t *pix1, *pix2;
  unsigned i_sum = 0;
  for( unsigned x = 0; x < 16; x++ )
    i_sum += abs( pix1[x] - pix2[x] );

To implement this, I moved some helper functions defined in `X86TargetLowering` into the parent class `TargetLowering` with minor generalization to reuse them from PPC backend.
Is this an acceptable approach or is it better to implement analysis as DAG combining (and introduce a new Opcode like ISD::SAD)?

This patch supports only ppc64le so far. If accepted, I will add big endian support and also POWER9 new instruction support.


https://reviews.llvm.org/D46101

Files:
  include/llvm/CodeGen/TargetLowering.h
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/PowerPC/ppc64_basicSAD.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46101.144053.patch
Type: text/x-patch
Size: 31079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180426/a1f9bf8e/attachment.bin>


More information about the llvm-commits mailing list