https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109088
--- Comment #12 from JuzheZhong <juzhe.zhong at rivai dot ai> --- (In reply to Richard Biener from comment #11) > I don't think strip_nop_cond_scalar_reduction is the place to adjust here, > maybe it's the caller. I don't have time to dig into the specific issue > right now but if we require scalar code adjustments then we need to perform > those in if-conversion. > > But to me it looks like allowing > > > > STMT 1. tmp = a[i] + x; > > > STMT 2. tmp2 = tmp + result_ssa_1; > > > STMT 3. result_ssa_2 = mask ? tmp2 : result_ssa_1; > > in vect_is_simple_reduction might also be a reasonable approach. The > use in the COND_EXPR isn't really a use - it's a conditional update. Thanks Richi. Enhancing vect_is_simple_reduction in loop vectorizer is also a good approach. But I think it's better to recognize the scalar condition reduction (if-conversion) as early as possible. Obviously, current if-conversion failed to recognize it as a feasible conditional reduction. I think enhancing vect_is_simple_reduction is the approach that it's unlikely we can simplify the scalar code in if-converison to fit current loop vectorizer. I believe we will eventually have to enhance both if-converison and loop vectorizer in the future. And I prefer improving the if-conversion and working on it. Will keep you posted. Thanks a lot!