https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64024
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, the problem is that we have during vector analysis: <bb 9>: # i_33 = PHI <0(8), i_25(11)> # ivtmp_27 = PHI <1024(8), ivtmp_26(11)> _17 = (unsigned short) i_33; _18 = _17 * 3; _20 = (int) _18; _22 = a[i_33]; _23 = foo (_22, pretmp_38, _20); c[i_33] = _23; i_25 = i_33 + 1; and simple_iv returns true for _20, despite the (unsigned short) cast in there, as 0 * 3 nor 1023 * 3 overflows. But during vector transform phase the bb is already: <bb 9>: # i_33 = PHI <i_46(28), i_25(11)> # ivtmp_27 = PHI <ivtmp_49(28), ivtmp_26(11)> # vect_vec_iv_.213_89 = PHI <vect_cst_.211_87(28), vect_vec_iv_.213_90(11)> # vectp_a.219_100 = PHI <vectp_a.220_98(28), vectp_a.219_101(11)> vect_vec_iv_.213_90 = vect_vec_iv_.213_89 + vect_cst_.212_88; vect_vec_iv_.213_92 = vect_vec_iv_.213_89 + vect_cst_.214_91; vect__17.215_93 = VEC_PACK_TRUNC_EXPR <vect_vec_iv_.213_89, vect_vec_iv_.213_92>; _17 = (unsigned short) i_33; vect__18.216_95 = vect__17.215_93 * vect_cst_.217_94; _18 = _17 * 3; vect__20.218_96 = [vec_unpack_lo_expr] vect__18.216_95; vect__20.218_97 = [vec_unpack_hi_expr] vect__18.216_95; _20 = (int) _18; vect__22.221_102 = MEM[(int *)vectp_a.219_100]; vectp_a.219_103 = vectp_a.219_100 + 16; vect__22.222_104 = MEM[(int *)vectp_a.219_103]; _22 = a[i_33]; _23 = foo (_22, pretmp_38, _20); c[i_33] = _23; i_25 = i_33 + 1; and in that case a) not sure if SCEV knows that the loop max bound is still 1024 b) as the initial value for i is an SSA_NAME, not constant, it also doesn't know it behaves as proper linear variable.