https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101419
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I agree about most of the passes you are moving, but I have an (albeit artificial) testcase that proves that cunrolli does affect objsz: __SIZE_TYPE__ a[10]; void foo (void) { char *p = __builtin_malloc (64); for (int i = 0; i < 4; i++) { a[i] = __builtin_object_size (p, 0); p += 6; } } When objsz is done before cunrolli, a[0] to a[3] will all be 64, while when it is done after cunrolli, it will be 64, 58, 52, 46. So, what about a mix of your and my patch, add --- gcc/passes.def +++ gcc/passes.def @@ -194,14 +194,14 @@ along with GCC; see the file COPYING3. If not see They ensure memory accesses are not indirect wherever possible. */ NEXT_PASS (pass_strip_predict_hints, false /* early_p */); NEXT_PASS (pass_ccp, true /* nonzero_p */); - NEXT_PASS (pass_post_ipa_warn); /* After CCP we rewrite no longer addressed locals into SSA form if possible. */ + NEXT_PASS (pass_post_ipa_warn); NEXT_PASS (pass_complete_unrolli); + NEXT_PASS (pass_object_sizes, false /* insert_min_max_p */); NEXT_PASS (pass_backprop); NEXT_PASS (pass_phiprop); NEXT_PASS (pass_forwprop); - NEXT_PASS (pass_object_sizes, false /* insert_min_max_p */); /* pass_build_alias is a dummy pass that ensures that we execute TODO_rebuild_alias at this point. */ NEXT_PASS (pass_build_alias); to my patch?