--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is the unsupported reduction. We can't vectorize a
x = x*x;
reduction. And I don't see how we could.
We could eventually vectorize the outer loop but outer loop vectorization
is "confused" by the if-conversion we need to do to the inner loop.
Fixing that (y *= n%2 ? x : 1) yields outer loop vectorization failure like
t.ii:20:20: note: vect_is_simple_use: operand y_36 = PHI <1(3),
prephitmp_27(10)>, type of def: unknown
t.ii:20:20: missed: Unsupported pattern.
t.ii:17:6: missed: not vectorized: unsupported use in stmt.
t.ii:20:20: missed: unexpected pattern.
t.ii:20:20: missed: couldn't vectorize loop
that is because we "simplified" the multiplication by 1 and thus the
reduction op becomes
y = n%2 ? new_y : y;
and appearantly we do not like this (not sure why the reduction structure
is relevant for outer loop vectorization). We do not actually detect this
as reduction, but we could simply identify inner loop reductions by
looking for the loop-closed PHIs.
So - were you expecting outer loop vectorization to happen?
* tree-vect-loop.c (vectorizable_reduction): Handle reduction
op with only phi inputs.
* tree-ssa-loop-ch.c: Include tree-ssa-sccvn.h.
(ch_base::copy_headers): Run CSE on copied loop headers.