https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61391
--- Comment #3 from Yuri Rumyantsev <ysrumyan at gmail dot com> --- A check that stmt-bb belongs to loop is missed in is_cond_scalar_reduction, if we add the following lines if (gimple_code (stmt) != GIMPLE_ASSIGN || gimple_has_volatile_ops (stmt)) return false; + + if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt))) + return false; test will be compiled successfully. I will prepare a patch after required testing completion.