https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113431
--- Comment #8 from JuzheZhong <juzhe.zhong at rivai dot ai> --- (In reply to Patrick O'Neill from comment #7) > (In reply to JuzheZhong from comment #6) > > (In reply to Patrick O'Neill from comment #5) > > > (In reply to JuzheZhong from comment #4) > > > > a[0][1] seems to be undefined value. > > > > > > a is a global variable so the elements are initialized to 0. a[0][1] is > > > within the bounds a[2][9]. > > > > Yes, I believe a[0][1] is 0. Then for all a[b][e] == a[0][1] == 0 should > > always be > > 1. > > > > Then if (!a[1][1]) should be false and then return 1; > > > > I failed to see anything wrong here. > > The value inside a[0][1] changes during the for loop. It starts out as 0 but > is changed to 1 when b=0,e=1. The elements in a after b=0,e=1 should be 1. > > Since a[1][1] is set after b=0,e=1 it should evaluate a[0][1]==0 to false > and set a[1][1] to 0. So I doubt it is not RISC-V backend issue. It's middle-end loop vectorizer issue. It's vectorized with evaluating whether it is 0 or not. Let's wait for Andrew confirm it.