Message ID | 87vaj6umru.fsf@linaro.org |
---|---|
State | New |
Headers | show |
Series | [17/nn] Turn var-tracking.c:INT_MEM_OFFSET into a function | expand |
On Mon, Oct 23, 2017 at 1:27 PM, Richard Sandiford <richard.sandiford@linaro.org> wrote: > This avoids the double evaluation mentioned in the comments and > simplifies the change to make MEM_OFFSET variable. Ok. Richard. > > 2017-10-23 Richard Sandiford <richard.sandiford@linaro.org> > Alan Hayward <alan.hayward@arm.com> > David Sherwood <david.sherwood@arm.com> > > gcc/ > * var-tracking.c (INT_MEM_OFFSET): Replace with... > (int_mem_offset): ...this new function. > (var_mem_set, var_mem_delete_and_set, var_mem_delete) > (find_mem_expr_in_1pdv, dataflow_set_preserve_mem_locs) > (same_variable_part_p, use_type, add_stores, vt_get_decl_and_offset): > Update accordingly. > > Index: gcc/var-tracking.c > =================================================================== > --- gcc/var-tracking.c 2017-09-12 14:28:56.401824826 +0100 > +++ gcc/var-tracking.c 2017-10-23 11:47:27.197231712 +0100 > @@ -390,8 +390,15 @@ struct variable > /* Pointer to the BB's information specific to variable tracking pass. */ > #define VTI(BB) ((variable_tracking_info *) (BB)->aux) > > -/* Macro to access MEM_OFFSET as an HOST_WIDE_INT. Evaluates MEM twice. */ > -#define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0) > +/* Return MEM_OFFSET (MEM) as a HOST_WIDE_INT, or 0 if we can't. */ > + > +static inline HOST_WIDE_INT > +int_mem_offset (const_rtx mem) > +{ > + if (MEM_OFFSET_KNOWN_P (mem)) > + return MEM_OFFSET (mem); > + return 0; > +} > > #if CHECKING_P && (GCC_VERSION >= 2007) > > @@ -2336,7 +2343,7 @@ var_mem_set (dataflow_set *set, rtx loc, > rtx set_src) > { > tree decl = MEM_EXPR (loc); > - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); > + HOST_WIDE_INT offset = int_mem_offset (loc); > > var_mem_decl_set (set, loc, initialized, > dv_from_decl (decl), offset, set_src, INSERT); > @@ -2354,7 +2361,7 @@ var_mem_delete_and_set (dataflow_set *se > enum var_init_status initialized, rtx set_src) > { > tree decl = MEM_EXPR (loc); > - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); > + HOST_WIDE_INT offset = int_mem_offset (loc); > > clobber_overlapping_mems (set, loc); > decl = var_debug_decl (decl); > @@ -2375,7 +2382,7 @@ var_mem_delete_and_set (dataflow_set *se > var_mem_delete (dataflow_set *set, rtx loc, bool clobber) > { > tree decl = MEM_EXPR (loc); > - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); > + HOST_WIDE_INT offset = int_mem_offset (loc); > > clobber_overlapping_mems (set, loc); > decl = var_debug_decl (decl); > @@ -4618,7 +4625,7 @@ find_mem_expr_in_1pdv (tree expr, rtx va > for (node = var->var_part[0].loc_chain; node; node = node->next) > if (MEM_P (node->loc) > && MEM_EXPR (node->loc) == expr > - && INT_MEM_OFFSET (node->loc) == 0) > + && int_mem_offset (node->loc) == 0) > { > where = node; > break; > @@ -4683,7 +4690,7 @@ dataflow_set_preserve_mem_locs (variable > /* We want to remove dying MEMs that don't refer to DECL. */ > if (GET_CODE (loc->loc) == MEM > && (MEM_EXPR (loc->loc) != decl > - || INT_MEM_OFFSET (loc->loc) != 0) > + || int_mem_offset (loc->loc) != 0) > && mem_dies_at_call (loc->loc)) > break; > /* We want to move here MEMs that do refer to DECL. */ > @@ -4727,7 +4734,7 @@ dataflow_set_preserve_mem_locs (variable > > if (GET_CODE (loc->loc) != MEM > || (MEM_EXPR (loc->loc) == decl > - && INT_MEM_OFFSET (loc->loc) == 0) > + && int_mem_offset (loc->loc) == 0) > || !mem_dies_at_call (loc->loc)) > { > if (old_loc != loc->loc && emit_notes) > @@ -5254,7 +5261,7 @@ same_variable_part_p (rtx loc, tree expr > else if (MEM_P (loc)) > { > expr2 = MEM_EXPR (loc); > - offset2 = INT_MEM_OFFSET (loc); > + offset2 = int_mem_offset (loc); > } > else > return false; > @@ -5522,7 +5529,7 @@ use_type (rtx loc, struct count_use_info > return MO_CLOBBER; > else if (target_for_debug_bind (var_debug_decl (expr))) > return MO_CLOBBER; > - else if (track_loc_p (loc, expr, INT_MEM_OFFSET (loc), > + else if (track_loc_p (loc, expr, int_mem_offset (loc), > false, modep, NULL) > /* Multi-part variables shouldn't refer to one-part > variable names such as VALUEs (never happens) or > @@ -6017,7 +6024,7 @@ add_stores (rtx loc, const_rtx expr, voi > rtx xexpr = gen_rtx_SET (loc, src); > if (same_variable_part_p (SET_SRC (xexpr), > MEM_EXPR (loc), > - INT_MEM_OFFSET (loc))) > + int_mem_offset (loc))) > mo.type = MO_COPY; > else > mo.type = MO_SET; > @@ -9579,7 +9586,7 @@ vt_get_decl_and_offset (rtx rtl, tree *d > if (MEM_ATTRS (rtl)) > { > *declp = MEM_EXPR (rtl); > - *offsetp = INT_MEM_OFFSET (rtl); > + *offsetp = int_mem_offset (rtl); > return true; > } > }
Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-09-12 14:28:56.401824826 +0100 +++ gcc/var-tracking.c 2017-10-23 11:47:27.197231712 +0100 @@ -390,8 +390,15 @@ struct variable /* Pointer to the BB's information specific to variable tracking pass. */ #define VTI(BB) ((variable_tracking_info *) (BB)->aux) -/* Macro to access MEM_OFFSET as an HOST_WIDE_INT. Evaluates MEM twice. */ -#define INT_MEM_OFFSET(mem) (MEM_OFFSET_KNOWN_P (mem) ? MEM_OFFSET (mem) : 0) +/* Return MEM_OFFSET (MEM) as a HOST_WIDE_INT, or 0 if we can't. */ + +static inline HOST_WIDE_INT +int_mem_offset (const_rtx mem) +{ + if (MEM_OFFSET_KNOWN_P (mem)) + return MEM_OFFSET (mem); + return 0; +} #if CHECKING_P && (GCC_VERSION >= 2007) @@ -2336,7 +2343,7 @@ var_mem_set (dataflow_set *set, rtx loc, rtx set_src) { tree decl = MEM_EXPR (loc); - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); + HOST_WIDE_INT offset = int_mem_offset (loc); var_mem_decl_set (set, loc, initialized, dv_from_decl (decl), offset, set_src, INSERT); @@ -2354,7 +2361,7 @@ var_mem_delete_and_set (dataflow_set *se enum var_init_status initialized, rtx set_src) { tree decl = MEM_EXPR (loc); - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); + HOST_WIDE_INT offset = int_mem_offset (loc); clobber_overlapping_mems (set, loc); decl = var_debug_decl (decl); @@ -2375,7 +2382,7 @@ var_mem_delete_and_set (dataflow_set *se var_mem_delete (dataflow_set *set, rtx loc, bool clobber) { tree decl = MEM_EXPR (loc); - HOST_WIDE_INT offset = INT_MEM_OFFSET (loc); + HOST_WIDE_INT offset = int_mem_offset (loc); clobber_overlapping_mems (set, loc); decl = var_debug_decl (decl); @@ -4618,7 +4625,7 @@ find_mem_expr_in_1pdv (tree expr, rtx va for (node = var->var_part[0].loc_chain; node; node = node->next) if (MEM_P (node->loc) && MEM_EXPR (node->loc) == expr - && INT_MEM_OFFSET (node->loc) == 0) + && int_mem_offset (node->loc) == 0) { where = node; break; @@ -4683,7 +4690,7 @@ dataflow_set_preserve_mem_locs (variable /* We want to remove dying MEMs that don't refer to DECL. */ if (GET_CODE (loc->loc) == MEM && (MEM_EXPR (loc->loc) != decl - || INT_MEM_OFFSET (loc->loc) != 0) + || int_mem_offset (loc->loc) != 0) && mem_dies_at_call (loc->loc)) break; /* We want to move here MEMs that do refer to DECL. */ @@ -4727,7 +4734,7 @@ dataflow_set_preserve_mem_locs (variable if (GET_CODE (loc->loc) != MEM || (MEM_EXPR (loc->loc) == decl - && INT_MEM_OFFSET (loc->loc) == 0) + && int_mem_offset (loc->loc) == 0) || !mem_dies_at_call (loc->loc)) { if (old_loc != loc->loc && emit_notes) @@ -5254,7 +5261,7 @@ same_variable_part_p (rtx loc, tree expr else if (MEM_P (loc)) { expr2 = MEM_EXPR (loc); - offset2 = INT_MEM_OFFSET (loc); + offset2 = int_mem_offset (loc); } else return false; @@ -5522,7 +5529,7 @@ use_type (rtx loc, struct count_use_info return MO_CLOBBER; else if (target_for_debug_bind (var_debug_decl (expr))) return MO_CLOBBER; - else if (track_loc_p (loc, expr, INT_MEM_OFFSET (loc), + else if (track_loc_p (loc, expr, int_mem_offset (loc), false, modep, NULL) /* Multi-part variables shouldn't refer to one-part variable names such as VALUEs (never happens) or @@ -6017,7 +6024,7 @@ add_stores (rtx loc, const_rtx expr, voi rtx xexpr = gen_rtx_SET (loc, src); if (same_variable_part_p (SET_SRC (xexpr), MEM_EXPR (loc), - INT_MEM_OFFSET (loc))) + int_mem_offset (loc))) mo.type = MO_COPY; else mo.type = MO_SET; @@ -9579,7 +9586,7 @@ vt_get_decl_and_offset (rtx rtl, tree *d if (MEM_ATTRS (rtl)) { *declp = MEM_EXPR (rtl); - *offsetp = INT_MEM_OFFSET (rtl); + *offsetp = int_mem_offset (rtl); return true; } }