https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111621
JuzheZhong <juzhe.zhong at rivai dot ai> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |juzhe.zhong at rivai dot ai --- Comment #3 from JuzheZhong <juzhe.zhong at rivai dot ai> --- I don't think this is a bug. You are using __riscv_vadd_vx_i32m4_m. The vd is not necessary same as vs2 and this intrinsic is supposed to use TAMA which means that the tailed element and mask-inactive elements are agnostic (can be either all ones or original value). So the codegen is correct even though -O0 result is different from -O2/-O3. If you want to use make vd same as vs2, you should use these following intrinsics: __riscv_vadd_vx_i32m4_tu __riscv_vadd_vx_i32m4_mu __riscv_vadd_vx_i32m4_tumu