"juzhe.zh...@rivai.ai" <juzhe.zh...@rivai.ai> writes: > Hi, Richard. Thanks for the comments. > >>> if (!LOOP_VINFO_USING_DECREMENTING_IV_P (loop_vinfo) >>> || !iv_rgc >>> || (iv_rgc->max_nscalars_per_iter * iv_rgc->factor >>> != rgc->max_nscalars_per_iter * rgc->factor)) >>> { > >> /* See whether zero-based IV would ever generate all-false > masks > >> or zero length before wrapping around. */ > >> bool might_wrap_p = vect_rgroup_iv_might_wrap_p (loop_vinfo, > rgc); > > >> /* Set up all controls for this group. */ > >> test_ctrl = vect_set_loop_controls_directly (loop, loop_vinfo, > >> &preheader_seq, > >> &header_seq, > >> loop_cond_gsi, > rgc, > >> niters, > niters_skip, > >> might_wrap_p); > > >> iv_rgc = rgc; > >> } > > > Could you tell me why you add: > (iv_rgc->max_nscalars_per_iter * iv_rgc->factor >>> != rgc->max_nscalars_per_iter * rgc->factor) ?
The patch creates IVs with the following step: gimple_seq_add_stmt (header_seq, gimple_build_assign (step, MIN_EXPR, index_before_incr, nitems_step)); If nitems_step is the same for two IVs, those IVs will always be equal. So having multiple IVs with the same nitems_step is redundant. nitems_step is calculated as follows: unsigned int nitems_per_iter = rgc->max_nscalars_per_iter * rgc->factor; ... poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo); ... if (nitems_per_iter != 1) { ... tree iv_factor = build_int_cst (iv_type, nitems_per_iter); ... nitems_step = gimple_build (preheader_seq, MULT_EXPR, iv_type, nitems_step, iv_factor); ... } so nitems_per_step is equal to: rgc->max_nscalars_per_iter * rgc->factor * VF VF is fixed for a loop, so nitems_step is equal for two different rgroup_controls if: rgc->max_nscalars_per_iter * rgc->factor is the same for those rgroup_controls. Please try the example I posted earlier today. I think you'll see that, without the: (iv_rgc->max_nscalars_per_iter * iv_rgc->factor != rgc->max_nscalars_per_iter * rgc->factor) you'll have two IVs with the same step (because their MIN_EXPRs have the same bound). Thanks, Richard