[06/11] Handle VMAT_INVARIANT separately
Invariant loads were handled as a variation on the code for contiguous
loads. We detected whether they were invariant or not as a byproduct of
creating the vector pointer ivs: vect_create_data_ref_ptr passed back an
inv_p to say whether the pointer was invariant.
But vectorised invariant loads just keep the original scalar load,
so this meant that detecting invariant loads had the side-effect of
creating an unwanted vector pointer iv. The placement of the code
also meant that we'd create a vector load and then not use the result.
In principle this is wrong code, since there's no guarantee that there's
a vector's worth of accessible data at that address, but we rely on DCE
to get rid of the load before any harm is done.
E.g., for an invariant load in an inner loop (which seems like the more
common use case for this code), we'd create:
vectp_a.6_52 = &a + 4;
# vectp_a.5_53 = PHI <vectp_a.5_54(9), vectp_a.6_52(2)>
# vectp_a.5_55 = PHI <vectp_a.5_53(3), vectp_a.5_56(10)>
vect_next_a_11.7_57 = MEM[(int *)vectp_a.5_55];
next_a_11 = a[_1];
vect_cst__58 = {next_a_11, next_a_11, next_a_11, next_a_11};
vectp_a.5_56 = vectp_a.5_55 + 4;
vectp_a.5_54 = vectp_a.5_53 + 0;
whereas all we want is:
next_a_11 = a[_1];
vect_cst__58 = {next_a_11, next_a_11, next_a_11, next_a_11};
This patch moves the handling to its own block and makes
vect_create_data_ref_ptr assert (when creating a full iv) that the
address isn't invariant.
The ncopies handling is unfortunate, but a preexisting issue.
Richi's suggestion of using a vector of vector statements would
let us reuse one statement for all copies.
2018-08-01 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-vectorizer.h (vect_create_data_ref_ptr): Remove inv_p
parameter.
* tree-vect-data-refs.c (vect_create_data_ref_ptr): Likewise.
When creating an iv, assert that the step is not known to be zero.
(vect_setup_realignment): Update call accordingly.
* tree-vect-stmts.c (vectorizable_store): Likewise.
(vectorizable_load): Likewise. Handle VMAT_INVARIANT separately.
From-SVN: r263220