Various ports have regressed the tree-ssa/ssa-dom-cse-2.c after this change: commit a4b48fc47c3406b6f41be093c4615879b7006710 Author: Richard Biener <rguenther@suse.de> Date: Mon May 18 16:05:00 2020 +0200 cost invariant nodes from vect_slp_analyze_node_operations SLP walk 2020-05-19 Richard Biener <rguenther@suse.de> * tree-vectorizer.h (_slp_tree::vectype): Add field. (SLP_TREE_VECTYPE): New. * tree-vect-slp.c (vect_create_new_slp_node): Initialize SLP_TREE_VECTYPE. (vect_create_new_slp_node): Likewise. (vect_prologue_cost_for_slp): Move here from tree-vect-stmts.c and simplify. (vect_slp_analyze_node_operations): Walk nodes children for invariant costing. (vect_get_constant_vectors): Use local scope op variable. * tree-vect-stmts.c (vect_prologue_cost_for_slp_op): Remove here. (vect_model_simple_cost): Adjust. (vect_model_store_cost): Likewise. (vectorizable_store): Likewise. You should be able to see this on the iq2000-elf port (and many others). I believe the test is supposed to verify that we're able to determine the return value statically after unrolling the loop. It's unclear if the stores get in the way of cse-ing the assignment to _22 and _29 in the dump or if there's something else going on: MEM[(int *)&a] = { 0 }; MEM[(int *)&a + 4B] = { 1 }; MEM[(int *)&a + 8B] = { 2 }; MEM[(int *)&a + 12B] = { 3 }; MEM[(int *)&a + 16B] = { 4 }; MEM[(int *)&a + 20B] = { 5 }; MEM[(int *)&a + 24B] = { 6 }; MEM[(int *)&a + 28B] = { 7 }; _22 = a[0]; _29 = a[1]; sum_30 = _22 + _29; _36 = a[2]; sum_37 = sum_30 + _36; _43 = a[3]; sum_44 = sum_37 + _43; _50 = a[4]; sum_51 = sum_44 + _50; _57 = a[5]; sum_58 = sum_51 + _57; _64 = a[6]; sum_65 = sum_58 + _64; _1 = a[7]; sum_16 = _1 + sum_65; a ={v} {CLOBBER}; return sum_16;
So SLP vectorization decides to vectorize the SImode stores with V1SImode vector stores because the cited revision does not cost the constant as SLP_TREE_NUMBER_OF_VEC_STMTS is zero for it. That's because this wasn't adjusted when changing what SLP node we pass in and we've never computed SLP_TREE_NUMBER_OF_VEC_STMTS for invariants sofar.
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:dc0c0196340f7ac58b10d0042d7cea776d6f7864 commit r11-615-gdc0c0196340f7ac58b10d0042d7cea776d6f7864 Author: Richard Biener <rguenther@suse.de> Date: Mon May 25 13:06:03 2020 +0200 tree-optimization/95309 - fix invariant SLP node costing This makes sure to compute SLP_TREE_NUMBER_OF_VEC_STMTS during SLP analysis even for invariant / external nodes so costing properly knows what to cost. 2020-05-25 Richard Biener <rguenther@suse.de> PR tree-optimization/95309 * tree-vect-slp.c (vect_get_constant_vectors): Move number of vector computation ... (vect_slp_analyze_node_operations): ... to analysis phase.
Fixed (on ip2000-elf).