Message ID | 20140529095256.GA44227@msticlxl57.ims.intel.com |
---|---|
State | New |
Headers | show |
On 05/29/14 04:53, Ilya Enkovich wrote: > Hi, > > This patch tries to keep bounds initial values when it may be needed. Even if initial value is not fully known (e.g. we know only low bound) it still may help to remove some redundant checks. > > Bootstrapped and tested on linux-x86_64. > > Thanks, > Ilya > -- > gcc/ > > 2013-05-29 Ilya Enkovich <ilya.enkovich@intel.com> > > * ipa.c (symtab_remove_unreachable_nodes): Kepp initial values for > pointer bounds to be used for checks eliminations. > * lto-cgraph.c (compute_ltrans_boundary): Likewise. > * add_references_to_partition (add_references_to_partition): Add > references to pointer bounds vars. Typo in the ChangeLog "kepp" -> "keep". OK for the trunk when the rest of the stuff is approved, though I'm curious how, for example, keeping the initial value for an unreachable node in symtab_remove_unreachable_nodes helps eliminate redundant checks. Jeff
On 30 May 10:45, Jeff Law wrote: > On 05/29/14 04:53, Ilya Enkovich wrote: > >Hi, > > > >This patch tries to keep bounds initial values when it may be needed. Even if initial value is not fully known (e.g. we know only low bound) it still may help to remove some redundant checks. > > > >Bootstrapped and tested on linux-x86_64. > > > >Thanks, > >Ilya > >-- > >gcc/ > > > >2013-05-29 Ilya Enkovich <ilya.enkovich@intel.com> > > > > * ipa.c (symtab_remove_unreachable_nodes): Kepp initial values for > > pointer bounds to be used for checks eliminations. > > * lto-cgraph.c (compute_ltrans_boundary): Likewise. > > * add_references_to_partition (add_references_to_partition): Add > > references to pointer bounds vars. > Typo in the ChangeLog "kepp" -> "keep". > > OK for the trunk when the rest of the stuff is approved, though I'm > curious how, for example, keeping the initial value for an > unreachable node in symtab_remove_unreachable_nodes helps eliminate > redundant checks. Consider we have some var 'arr' and static bounds '__chkp_bounds_of_arr' holding its bounds. Upper bound may be unknown at compile time and therefore '__chkp_bounds_of_arr' is not a candidate for constant folding. But we always know low bound which is '&arr'. It means we may remove checks of low bound when value of '__chkp_bounds_of_arr' is used in checks. That is why I want to keep initials for all static bounds vars. Here is fixed ChangeLog. Thanks, Ilya -- gcc/ 2014-06-02 Ilya Enkovich <ilya.enkovich@intel.com> * ipa.c (symtab_remove_unreachable_nodes): Keep initial values for pointer bounds to be used for checks eliminations. * lto-cgraph.c (compute_ltrans_boundary): Likewise. * add_references_to_partition (add_references_to_partition): Add references to pointer bounds vars. > > Jeff >
diff --git a/gcc/ipa.c b/gcc/ipa.c index 1d7fa35..958cabe 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -568,7 +568,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file) vnode->aux = NULL; /* Keep body if it may be useful for constant folding. */ - if ((init = ctor_for_folding (vnode->decl)) == error_mark_node) + if ((init = ctor_for_folding (vnode->decl)) == error_mark_node + && !POINTER_BOUNDS_P (vnode->decl)) varpool_remove_initializer (vnode); else DECL_INITIAL (vnode->decl) = init; diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 58105f0..7089516 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -829,7 +829,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) { if (!lto_symtab_encoder_encode_initializer_p (encoder, vnode) - && ctor_for_folding (vnode->decl) != error_mark_node) + && (ctor_for_folding (vnode->decl) != error_mark_node + || POINTER_BOUNDS_P (vnode->decl))) { lto_set_symtab_encoder_encode_initializer (encoder, vnode); add_references (encoder, &vnode->ref_list); diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 2967d73..330253b 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -96,7 +96,8 @@ add_references_to_partition (ltrans_partition part, symtab_node *node) Recursively look into the initializers of the constant variable and add references, too. */ else if (is_a <varpool_node> (ref->referred) - && ctor_for_folding (ref->referred->decl) != error_mark_node + && (ctor_for_folding (ref->referred->decl) != error_mark_node + || POINTER_BOUNDS_P (ref->referred->decl)) && !lto_symtab_encoder_in_partition_p (part->encoder, ref->referred)) { if (!part->initializers_visited)