https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113134
--- Comment #17 from JuzheZhong <juzhe.zhong at rivai dot ai> --- (In reply to Tamar Christina from comment #16) > > > > I wonder whether ARM SVE can also use this approach VEC_EXTRACT with index = > > 0. > > Perhaps, I'll look into it thanks. though this is ofcourse only applicable > when the mask comes from whilelo. > > In the future when we get to loops such as: > > for (int i = ..;;) > { > if (a) > { > .... > if (b) > return i; > } > } > > the reduction would come from the first active element of the mask created > by the condition a and not the whilelo. If the mask comes from a condition, VEC_EXTRACT approach is definitely incorrect. However, look into vectorizable_live_operation_1: The mask should always come from whilo instruction (or say it is always loop mask): tree mask = vect_get_loop_mask (loop_vinfo, &gsi, &LOOP_VINFO_MASKS (loop_vinfo), 1, vectype, 0); So I think it should be correct using VEC_EXTRACT with index = 0. But if we look into vectorizable_early_break which will handle mask come from condition, that is another story.