We have this comment in tree-vect-analyze.c, in
vect_determine_vectorization_facor():
"
/* We set the vectype according to the type of the result (lhs).
For stmts whose result-type is different than the type of the
arguments (e.g. demotion, promotion), vectype will be reset
appropriately (later). Note that we have to visit the smallest
datatype in this function, because that determines the VF.
If the smallest datatype in the loop is present only as the
rhs of a promotion operation - we'd miss it here.
However, in such a case, that a variable of this datatype
does not appear in the lhs anywhere in the loop, it shouldn't
affect the vectorization factor. */
"
The problem is, that some computations, e.g. - the recently added
induction, are defined by a loop-header-phi-node, and we don't traverse phi
nodes in this function, only stmts... so exactly what we warn about in the
comment happens in the testcase that ICEs.
This patch adds a loop that does pretty much the same as the loop that
traverses all stmts, only for phis - looking for the smallest type over all
phis. In order to avoid considering irrelevant phis, we change
vect_mark_stmts_to_be_vectorized() to also mark phis as relevant (when they
are) - before we just skipped them cause we never vectorize phis.
Bootstrapped on powerpc-linux and i386-linux, tested on the vectorizer
testcases on both platforms.
Ok once passes complete make-check?
PR tree-optimization/30771
* tree-vect-analyze.c (vect_determine_vectorization_factor): Traverse
also phi nodes.
(vect_analyze_operations): Induction phis can now be marked as
used_in_loop.
(vect_mark_stmts_to_be_vectorized): No special treatment for phis.
Update documentation accordingly.
testsuite/ChangeLog:
PR tree-optimization/30771
* gcc.dg/vect/pr30771.c: New test.
(See attached file: pr30771.fix.txt)