https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87288
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work| |7.3.1 Target Milestone|--- |8.3 Summary|Segfault after const_cast |[8/9 Regression] Segfault |with "-O2 |after const_cast with "-O2 |-ftree-loop-vectorize" but |-ftree-loop-vectorize" but |_without_ "-mavx" |_without_ "-mavx" Known to fail| |8.2.1 --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- -fno-tree-bit-ccp happens to fix the bug but it looks latent (same bogus value-range). Value-ranges appear from DOM and the [1, ...] one first appears with the vect pass: t.C.160t.ifcvt: # RANGE ~[2147483648, 18446744071562067967] t.C.160t.ifcvt: # RANGE [0, 18446744073709551600] t.C.160t.ifcvt: # RANGE [-2147483647, 2147483647] t.C.161t.vect: # RANGE [1, 2147483647] NONZERO 2147483647 t.C.161t.vect: # RANGE ~[2147483648, 18446744071562067967] t.C.161t.vect: # RANGE [0, 18446744073709551600] t.C.161t.vect: # RANGE [-2147483647, 2147483647] t.C.161t.vect: # RANGE ~[2147483648, 18446744071562067967] t.C.161t.vect: # RANGE [0, 18446744073709551600] t.C.161t.vect: # RANGE [-2147483647, 2147483647] it's set here: if (!is_gimple_val (niters_vector)) { var = create_tmp_var (type, "bnd"); gimple_seq stmts = NULL; niters_vector = force_gimple_operand (niters_vector, &stmts, true, var); gsi_insert_seq_on_edge_immediate (pe, stmts); /* Peeling algorithm guarantees that vector loop bound is at least ONE, we set range information to make niters analyzer's life easier. */ if (stmts != NULL && log_vf) set_range_info (niters_vector, VR_RANGE, wi::to_wide (build_int_cst (type, 1)), wi::to_wide (fold_build2 (RSHIFT_EXPR, type, TYPE_MAX_VALUE (type), log_vf))); and the loop is <bb 5> [local count: 105119325]: niters.0_25 = (unsigned int) n_15; ni_gap.1_36 = niters.0_25 + 4294967295; # RANGE [1, 2147483647] NONZERO 2147483647 bnd.2_37 = ni_gap.1_36 >> 1; <bb 4> [local count: 567644349]: # ivtmp_50 = PHI <ivtmp_51(6), 0(5)> ivtmp_51 = ivtmp_50 + 1; if (ivtmp_51 >= bnd.2_37) goto <bb 12>; [16.67%] else goto <bb 6>; [83.33%] <bb 6> [local count: 473036958]: goto <bb 4>; [100.00%] which looks good according to the comment. So the number of iterations _is_ bnd.2_37 - 1 (that number may be zero).