Message ID | 1513562874-38507-1-git-send-email-dmalcolm@redhat.com |
---|---|
State | New |
Headers | show |
Series | None | expand |
On Sun, Dec 17, 2017 at 09:07:54PM -0500, David Malcolm wrote: > What do you think? > > Successfully bootstrapped®rtested on x86_64-pc-linux-gnu, as > part of the kit. > > gcc/ChangeLog: > * fold-const.c (operand_equal_p): Strip any location wrappers, > before computing hashes. > --- > gcc/fold-const.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/gcc/fold-const.c b/gcc/fold-const.c > index 0f11076..2b938900 100644 > --- a/gcc/fold-const.c > +++ b/gcc/fold-const.c > @@ -2804,6 +2804,9 @@ combine_comparisons (location_t loc, > int > operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) > { > + STRIP_ANY_LOCATION_WRAPPER (arg0); > + STRIP_ANY_LOCATION_WRAPPER (arg1); > + Certainly not at this spot. The checking that hashing ignores the location wrappers needs to be done first. And inchash:add_expr needs to ignore those. Jakub
On 12/17/2017 09:07 PM, David Malcolm wrote: > On Mon, 2017-12-11 at 18:37 -0500, Jason Merrill wrote: >> On 11/10/2017 04:45 PM, David Malcolm wrote: >>> gcc/c-family/ChangeLog: >>> * c-warn.c (sizeof_pointer_memaccess_warning): Strip any >>> location >>> wrappers from src and dest. >> >> Here the existing calls to tree_strip_nop_conversions ought to >> handle >> the wrappers. > > They don't; when EXP is a VIEW_CONVERT_EXPR wrapper around a VAR_DECL... > > 11887 static inline bool > 11888 tree_nop_conversion (const_tree exp) > 11889 { > 11890 tree outer_type, inner_type; > 11891 > 11892 if (!CONVERT_EXPR_P (exp) > 11893 && TREE_CODE (exp) != NON_LVALUE_EXPR) > 11894 return false; > > ...tree_nop_conversion bails out at this "return false;", and hence > tree_strip_nop_conversions simply returns the wrapper that was passed > in. Right. So let's change tree_nop_conversion to return true. Jason
On Tue, Dec 19, 2017 at 03:13:13PM -0500, Jason Merrill wrote: > On 12/17/2017 09:07 PM, David Malcolm wrote: > > On Mon, 2017-12-11 at 18:37 -0500, Jason Merrill wrote: > > > On 11/10/2017 04:45 PM, David Malcolm wrote: > > > > gcc/c-family/ChangeLog: > > > > * c-warn.c (sizeof_pointer_memaccess_warning): Strip any > > > > location > > > > wrappers from src and dest. > > > > > > Here the existing calls to tree_strip_nop_conversions ought to > > > handle > > > the wrappers. > > > > They don't; when EXP is a VIEW_CONVERT_EXPR wrapper around a VAR_DECL... > > > > 11887 static inline bool > > 11888 tree_nop_conversion (const_tree exp) > > 11889 { > > 11890 tree outer_type, inner_type; > > 11891 > > 11892 if (!CONVERT_EXPR_P (exp) > > 11893 && TREE_CODE (exp) != NON_LVALUE_EXPR) > > 11894 return false; > > > > ...tree_nop_conversion bails out at this "return false;", and hence > > tree_strip_nop_conversions simply returns the wrapper that was passed > > in. > > Right. So let's change tree_nop_conversion to return true. I'd fear that would break too much stuff, VIEW_CONVERT_EXPR is not a normal conversion, but reinterpretation of the bits. Or do you mean it should strip just the special VIEW_CONVERT_EXPR that has type identical to the operand's type? Jakub
On Tue, Dec 19, 2017 at 3:49 PM, Jakub Jelinek <jakub@redhat.com> wrote: > On Tue, Dec 19, 2017 at 03:13:13PM -0500, Jason Merrill wrote: >> On 12/17/2017 09:07 PM, David Malcolm wrote: >> > On Mon, 2017-12-11 at 18:37 -0500, Jason Merrill wrote: >> > > On 11/10/2017 04:45 PM, David Malcolm wrote: >> > > > gcc/c-family/ChangeLog: >> > > > * c-warn.c (sizeof_pointer_memaccess_warning): Strip any >> > > > location >> > > > wrappers from src and dest. >> > > >> > > Here the existing calls to tree_strip_nop_conversions ought to >> > > handle >> > > the wrappers. >> > >> > They don't; when EXP is a VIEW_CONVERT_EXPR wrapper around a VAR_DECL... >> > >> > 11887 static inline bool >> > 11888 tree_nop_conversion (const_tree exp) >> > 11889 { >> > 11890 tree outer_type, inner_type; >> > 11891 >> > 11892 if (!CONVERT_EXPR_P (exp) >> > 11893 && TREE_CODE (exp) != NON_LVALUE_EXPR) >> > 11894 return false; >> > >> > ...tree_nop_conversion bails out at this "return false;", and hence >> > tree_strip_nop_conversions simply returns the wrapper that was passed >> > in. >> >> Right. So let's change tree_nop_conversion to return true. > > I'd fear that would break too much stuff, VIEW_CONVERT_EXPR is not > a normal conversion, but reinterpretation of the bits. > > Or do you mean it should strip just the special VIEW_CONVERT_EXPR > that has type identical to the operand's type? That; interpreting something as the same type seems like a nop. Jason
On Tue, Dec 19, 2017 at 04:59:34PM -0500, Jason Merrill wrote: > > Or do you mean it should strip just the special VIEW_CONVERT_EXPR > > that has type identical to the operand's type? > > That; interpreting something as the same type seems like a nop. Ok, that makes sense. Jakub
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0f11076..2b938900 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2804,6 +2804,9 @@ combine_comparisons (location_t loc, int operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) { + STRIP_ANY_LOCATION_WRAPPER (arg0); + STRIP_ANY_LOCATION_WRAPPER (arg1); + /* When checking, verify at the outermost operand_equal_p call that if operand_equal_p returns non-zero then ARG0 and ARG1 has the same hash value. */