https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102756
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2021-10-15 Keywords| |missed-optimization Summary|[12 Regression] Vectorizer |[12 Regression] Complete |change creates poor code |unrolling is too senative |for |to PRE; |c-c++-common/torture/vector |c-c++-common/torture/vector |-compare-2.c |-compare-2.c Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- With -ftree-vectorize size: 7-4, last_iteration: 7-4 Loop size: 7 Estimated size after unrolling: 8 _1 = VIEW_CONVERT_EXPR<int[4]>(r)[i_10]; With -fno-tree-vectorize size: 7-4, last_iteration: 6-4 Loop size: 7 Estimated size after unrolling: 7 pretmp_2 = MEM[(vector(4) int *)&r][i_7]; Also -O2 -fno-tree-vectorize -fno-tree-pre produces the same as the -O2 -ftree-vectorize case. ------------------- CUT ---------------------------- Loop 1 iterates 3 times. Loop 1 iterates at most 3 times. Loop 1 likely iterates at most 3 times. Estimating sizes for loop 1 BB: 3, after_exit: 0 size: 1 _1 = VIEW_CONVERT_EXPR<int[4]>(r)[i_10]; size: 2 if (_1 != -3) BB: 7, after_exit: 1 BB: 5, after_exit: 0 size: 1 i_7 = i_10 + 1; Induction variable computation will be folded away. size: 1 ivtmp_9 = ivtmp_2 - 1; Induction variable computation will be folded away. size: 2 if (ivtmp_9 != 0) Exit condition will be eliminated in peeled copies. Exit condition will be eliminated in last copy. Constant conditional. size: 7-4, last_iteration: 7-4 Loop size: 7 Estimated size after unrolling: 8 Not unrolling loop 1: size would grow. vs: Estimating sizes for loop 1 BB: 3, after_exit: 0 size: 2 if (prephitmp_9 != -3) BB: 6, after_exit: 1 size: 1 pretmp_2 = MEM[(vector(4) int *)&r][i_7]; BB: 5, after_exit: 0 size: 1 i_7 = i_10 + 1; Induction variable computation will be folded away. size: 1 ivtmp_11 = ivtmp_1 - 1; Induction variable computation will be folded away. size: 2 if (ivtmp_11 != 0) Exit condition will be eliminated in peeled copies. Exit condition will be eliminated in last copy. Constant conditional. size: 7-4, last_iteration: 6-4 Loop size: 7 Estimated size after unrolling: 7 PRE decides to do the load for MEM[(vector(4) int *)&r][0] which is why the last iteration is 6-4 rather than 7-4.