Re: [PATCH] Remove unnecessary conditional in get_odr_type (PR rtl-optimization/77425)
On Fri, Sep 2, 2016 at 5:07 PM, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, we have > static GTY(()) vec *odr_types_ptr; > #define odr_types (*odr_types_ptr) > and in the else block do > odr_types[val->id] = 0; > first (which is actually > (*odr_types_ptr)[val->id] = 0; > without the obfuscation) and then > if (odr_types_ptr) > ... > odr_types_ptr is known to be non-NULL in this case, otherwise it couldn't be > dereferenced first - it can be NULL only when nothing has been added yet, > but that happens only if the then path is taken. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok. Richard. > 2016-09-02 Jakub Jelinek > > PR rtl-optimization/77425 > * ipa-devirt.c (get_odr_type): Set val->id unconditionally. > > --- gcc/ipa-devirt.c.jj 2016-04-14 21:20:19.0 +0200 > +++ gcc/ipa-devirt.c2016-09-01 12:42:07.077740393 +0200 > @@ -2136,8 +2136,7 @@ get_odr_type (tree type, bool insert) >/* Be sure we did not recorded any derived types; these may need > renumbering too. */ >gcc_assert (val->derived_types.length() == 0); > - if (odr_types_ptr) > - val->id = odr_types.length (); > + val->id = odr_types.length (); >vec_safe_push (odr_types_ptr, val); > } >return val; > > Jakub
[PATCH] Remove unnecessary conditional in get_odr_type (PR rtl-optimization/77425)
Hi! As mentioned in the PR, we have static GTY(()) vec *odr_types_ptr; #define odr_types (*odr_types_ptr) and in the else block do odr_types[val->id] = 0; first (which is actually (*odr_types_ptr)[val->id] = 0; without the obfuscation) and then if (odr_types_ptr) ... odr_types_ptr is known to be non-NULL in this case, otherwise it couldn't be dereferenced first - it can be NULL only when nothing has been added yet, but that happens only if the then path is taken. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-09-02 Jakub Jelinek PR rtl-optimization/77425 * ipa-devirt.c (get_odr_type): Set val->id unconditionally. --- gcc/ipa-devirt.c.jj 2016-04-14 21:20:19.0 +0200 +++ gcc/ipa-devirt.c2016-09-01 12:42:07.077740393 +0200 @@ -2136,8 +2136,7 @@ get_odr_type (tree type, bool insert) /* Be sure we did not recorded any derived types; these may need renumbering too. */ gcc_assert (val->derived_types.length() == 0); - if (odr_types_ptr) - val->id = odr_types.length (); + val->id = odr_types.length (); vec_safe_push (odr_types_ptr, val); } return val; Jakub