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.
In a more general setting we probably need to support ABS(SUB(ZEXT(x)), ZEXT(y))) as well