This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Generalize get_most_common_single_value to return k_th value & count


On Mon, Jul 15, 2019 at 11:20:34AM +0200, Martin Liška wrote:
> On 7/15/19 10:20 AM, Xiong Hu Luo wrote:
> > -/* Return most common value of TOPN_VALUE histogram.  If
> > -   there's a unique value, return true and set VALUE and COUNT
> > +struct value_count_t {
> > +  gcov_type value;
> > +  gcov_type count;
> > +};
> 
> I like introduction of the tuple, please fix GNU coding style: '{' shoud
> be on the next line.

Only in function definitions.

> > +static int
> > +cmp_counts (const void *v1, const void *v2)
> > +{
> > +  const_value_count h1 = (const_value_count) v1;
> > +  const_value_count h2 = (const_value_count) v2;
> > +  if (h1->count < h2->count)
> > +    return 1;
> > +  if (h1->count > h2->count)
> > +    return -1;
> > +  return 0;
> > +}
> 
> In order to provide stable results, we want secondary comparison based on 'value'.

Is that enough?  Can there be two entries with the same count as well
as value?


Segher


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]