Commit d2694766 authored by Richard Sandiford's avatar Richard Sandiford
Browse files

vect: Try to remove single-vector permutes from SLP graph

This patch extends the SLP layout optimisation pass so that it
tries to remove layout changes that are brought about by permutes
of existing vectors.  This fixes the bb-slp-pr54400.c regression on
x86_64 and also means that we can remove the permutes in cases like:

typedef float v4sf __attribute__((vector_size(sizeof(float)*4)));

float __attribute__((noipa))
f(v4sf v0, v4sf v1)
{
  return v0[0]*v1[0]+v0[1]*v1[1]+v0[2]*v1[2]+v0[3]*v1[3];
}

The new test is a simple adaption of bb-slp-pr54400.c, with the
same style of markup.

gcc/
	* tree-vect-slp.cc (vect_build_slp_tree_2): When building a
	VEC_PERM_EXPR of an existing vector, set the SLP_TREE_LANES
	to the number of vector elements, if that's a known constant.
	(vect_optimize_slp_pass::is_compatible_layout): Remove associated
	comment about zero SLP_TREE_LANES.
	(vect_optimize_slp_pass::start_choosing_layouts): Iterate over
	all partition members when looking for potential layouts.
	Handle existing permutes of fixed-length vectors.

gcc/testsuite/
	* gcc.dg/vect/bb-slp-pr54400.c: Extend to aarch64.
	* gcc.dg/vect/bb-slp-layout-18.c: New test.
parent 5205f5b5
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment