public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Martin Jambor <mjambor@suse.cz>,
	       Prathamesh Kulkarni	 <prathamesh.kulkarni@linaro.org>
Cc: Richard Biener <rguenther@suse.de>, Jan Hubicka <hubicka@ucw.cz>,
	       Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>,
	       gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] ipa bitwise constant propagation
Date: Mon, 08 Aug 2016 14:29:00 -0000	[thread overview]
Message-ID: <1470666553.8203.110.camel@redhat.com> (raw)
In-Reply-To: <20160808140355.sbi7zufcjeieek2p@virgil.suse.cz>

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 <mjambor@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	other threads:[~2016-08-08 14:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  6:36 Prathamesh Kulkarni
2016-08-04  8:02 ` Richard Biener
2016-08-04  8:57   ` Prathamesh Kulkarni
2016-08-04  9:07     ` kugan
2016-08-04 10:51     ` Richard Biener
2016-08-04 13:05   ` Jan Hubicka
2016-08-04 23:04     ` kugan
2016-08-05 11:36       ` Jan Hubicka
2016-08-05 12:37 ` Martin Jambor
2016-08-07 21:38   ` Prathamesh Kulkarni
2016-08-08 14:04     ` Martin Jambor
2016-08-08 14:29       ` David Malcolm [this message]
2016-08-09  8:11       ` Prathamesh Kulkarni
2016-08-09  9:24         ` Richard Biener
2016-08-09 11:09         ` Martin Jambor
2016-08-09 11:47           ` Prathamesh Kulkarni
2016-08-09 18:13             ` Martin Jambor
2016-08-10  8:45               ` Prathamesh Kulkarni
2016-08-10 11:35                 ` Prathamesh Kulkarni
2016-08-11 12:55                   ` Jan Hubicka
2016-08-12  9:54                     ` Prathamesh Kulkarni
2016-08-12 14:04                       ` Jan Hubicka
2016-08-16 13:05                         ` Prathamesh Kulkarni
2016-08-22 13:33                           ` Martin Jambor
2016-08-22 13:55                             ` Prathamesh Kulkarni
2016-08-24 12:07                               ` Prathamesh Kulkarni
2016-08-25 13:44                                 ` Jan Hubicka
2016-08-26 12:31                                   ` Prathamesh Kulkarni
2016-08-26 16:23                                 ` Rainer Orth
2016-08-26 17:23                                   ` Prathamesh Kulkarni
2016-08-29 10:53                                     ` Christophe Lyon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470666553.8203.110.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=kugan.vivekanandarajah@linaro.org \
    --cc=mjambor@suse.cz \
    --cc=prathamesh.kulkarni@linaro.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).