aarch64: name the saturating narrow patterns after the sstrunc and ustrunc optabs

vect_recog_sat_trunc_pattern only forms .SAT_TRUNC when the target has the
sstrunc or ustrunc optab for the mode pair, and the backend had neither, even
though aarch64_<su>qmovn<mode> already matches exactly the RTL those optabs
describe.  A saturating narrowing loop was therefore vectorised as a pair of
clamps and a permute:

  static inline unsigned char clip (unsigned short x)
  { return x & ~255 ? 255 : x; }
  for (i) r[i] = clip (x[i]);

  before				after

  movi	v29.8h, 0xff			ldp	q30, q31, [x1], 32
  ldp	q31, q30, [x1], 32		uqxtn	v30.8b, v30.8h
  umin	v31.8h, v31.8h, v29.8h		uqxtn	v31.8b, v31.8h
  umin	v30.8h, v30.8h, v29.8h		stp	d30, d31, [x0], 16
  uzp1	v31.16b, v31.16b, v30.16b
  str	q31, [x0], 16

and the signed form was worse still, needing two constants and a pair of
compares per half.  Only the standard names were missing, so this adds the
expander and leaves the existing insn to match it.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

	* config/aarch64/iterators.md (vnarrowq): New mode attribute.
	(sat_trunc_op): New code attribute.
	* config/aarch64/aarch64-simd.md (<sat_trunc_op>trunc<mode><vnarrowq>2):
	New expander.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/vect-sat-trunc-1.c: New test.
	* gcc.target/aarch64/vect-sat-trunc-2.c: New test.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
4 files changed