On Mon, 2016-08-08 at 16:03 +0200, Martin Jambor wrote:
> Hi,
> 
> thanks for following through.  You'll need an approval from Honza,
> but
> I think the code looks good (I have looked at the places that I
> believe have changed since the last week).  However, I have
> discovered
> one new thing I don't like and still believe you need to handle
> different precisions in lattice need:
> 
> On Mon, Aug 08, 2016 at 03:08:35AM +0530, Prathamesh Kulkarni wrote:
> > On 5 August 2016 at 18:06, Martin Jambor <mjam...@suse.cz> wrote:
> > 
> > ...
> > 
> > > > diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> > > > index 5b6cb9a..b770f6a 100644
> > > > --- a/gcc/ipa-cp.c
> > > > +++ b/gcc/ipa-cp.c
> > > > @@ -120,6 +120,7 @@ along with GCC; see the file COPYING3.  If
> > > > not see
> > > >  #include "params.h"
> > > >  #include "ipa-inline.h"
> > > >  #include "ipa-utils.h"
> > > > +#include "tree-ssa-ccp.h"
> > > > 
> > > >  template <typename valtype> class ipcp_value;
> > > > 
> > > > @@ -266,6 +267,40 @@ private:
> > > >    bool meet_with_1 (unsigned new_align, unsigned
> > > > new_misalign);
> > > >  };
> > > > 
> > > > +/* Lattice of known bits, only capable of holding one value.
> > > > +   Similar to ccp_prop_value_t, mask represents which bits of
> > > > value are constant.
> > > > +   If a bit in mask is set to 0, then the corresponding bit in
> > > > +   value is known to be constant.  */
> > > > +
> > > > +class ipcp_bits_lattice
> > > > +{
> > > > +public:
> > > > +  bool bottom_p () { return lattice_val == IPA_BITS_VARYING; }
> > > > +  bool top_p () { return lattice_val == IPA_BITS_UNDEFINED; }
> > > > +  bool constant_p () { return lattice_val ==
> > > > IPA_BITS_CONSTANT; }
> > > > +  bool set_to_bottom ();
> > > > +  bool set_to_constant (widest_int, widest_int, signop,
> > > > unsigned);
> > > > +
> > > > +  widest_int get_value () { return value; }
> > > > +  widest_int get_mask () { return mask; }
> > > > +  signop get_sign () { return sgn; }
> > > > +  unsigned get_precision () { return precision; }
> > > > +
> > > > +  bool meet_with (ipcp_bits_lattice& other, enum tree_code,
> > > > tree);
> > > > +  bool meet_with (widest_int, widest_int, signop, unsigned);
> > > > +
> > > > +  void print (FILE *);
> > > > +
> > > > +private:
> > > > +  enum { IPA_BITS_UNDEFINED, IPA_BITS_CONSTANT,
> > > > IPA_BITS_VARYING } lattice_val;
> > > > +  widest_int value, mask;
> > > > +  signop sgn;
> > > > +  unsigned precision;
> 
> I know that the existing code in ipa-cp.c does not do this, but
> please
> prefix member variables with "m_" like our coding style guidelines
> suggest (or even require?).  You routinely reuse those same names in
> names of parameters of meet_with and I believe that is a practice
> that
> will sooner or later lead to confusing the two and bugs.

I'm not a reviewer, and not very familiar with this code, but is it
possible to add a couple of examples to the descriptive comment of
 class ipcp_bits_lattice?  I'm finding it hard to understand how the
various fields interact, in particular "value" and "mask" interact (or
rather "m_value" and "m_mask").  I think a concrete example would make
things much clearer.  This thread talked about this below...

[...]

> > > It is probably just me not being particularly sharp on a Friday
> > > afternoon and I might not understand the semantics of mask well
> > > (also,
> > > you did not document it :-), but... assume that we are looking at
> > > a
> > > binary and operation, other comes from an SSA pointer and its
> > > mask
> > > would be binary 100 and its value 0 because that's what you set
> > > for
> > > ssa names in ipa-prop.h, and the operand is binary value 101,
> > > which
> > > means that get_value_and_mask returns mask 0 and value 101.  Now,
> > > bit_value_binop_1 would return value 0 & 101 = 0 and mask
> > > according to
> > > 
> > > (m1 | m2) & ((v1 | m1) & (v2 | m2))
> > > 
> > > so in our case
> > > 
> > > (100b & 0) & ((0 | 100b) & (101b | 0)) = 0 & 100b = 0.
> > Shouldn't this be:
> > (100b | 0) & ((0 | 100b) & (101b | 0)) = 100 & 100 = 100 -;)
> 
> Eh, right, sorry.  I just find the term mask confusing when we do not
> actually mask anything with it (but I guess it is good to be
> consistent so let's keep it).

...so presumably it would be good to capture something like that within
the descriptive comment of the class.

[...]

Hope this is constructive
Dave

Reply via email to