On Thu, 26 Mar 2015, Jakub Jelinek wrote: > On Thu, Mar 26, 2015 at 10:32:18AM +0100, Richard Biener wrote: > > I think I simply didn't want to change more testcases at that point, > > but I can't see how followup passes at the very point wouldn't > > clean things up very quickly (via fre or copyprop). Eventually > > it was -Og and pass_fold_builtins interaction (thinking of > > __builtin_constant_p (__builtin_object_size (...)) or so). > > If so I'm sure I added a testcase. > > Can't find such a testcase. > Anyway, the shorter version of the patch regresses: > > struct S { char a[10]; char b[10]; }; > int > foo (int x) > { > struct S s; > char *p = &s.a[4]; > if (x) > p += 1; > return __builtin_constant_p (__builtin_object_size (p, 1)); > } > > with -Og, while it works with the longer version. > > Though, say for > return __builtin_constant_p (__builtin_object_size (p, 1) + 1); > > we already return 0 for -Og (and not -O2) already in 4.9.
Yeah, I think for -Og ideally both pass_object_sizes and pass_fold_builtins should run from pass_ccp. We do have some pass ordering issue in -Og otherwise. It's pipeline would then also simplify to Index: gcc/passes.def =================================================================== --- gcc/passes.def (revision 221689) +++ gcc/passes.def (working copy) @@ -314,13 +314,7 @@ along with GCC; see the file COPYING3. NEXT_PASS (pass_lower_complex); NEXT_PASS (pass_lower_vector_ssa); /* Perform simple scalar cleanup which is constant/copy propagation. */ - NEXT_PASS (pass_ccp); - NEXT_PASS (pass_object_sizes); - /* Fold remaining builtins. */ - NEXT_PASS (pass_fold_builtins); - /* Copy propagation also copy-propagates constants, this is necessary - to forward object-size and builtin folding results properly. */ - NEXT_PASS (pass_copy_prop); + NEXT_PASS (pass_ccp_with_objsize_and_fab); NEXT_PASS (pass_dce); NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); well, at least if ccp would also propagate copies... (I'd really like to unify CCP and copyprop and have some flags to control what it performs). So the above would probably need a copyprop before that pass_ccp_with_objsize_and_fab, or teaching ccp to also propagate copies (lattice value CONSTANT, value == SSA_NAME and mask == ~0). I wouldn't care about this for GCC 5. Richard.