On Wed, Oct 31, 2018 at 5:11 PM Richard Biener <richard.guent...@gmail.com> wrote: > > On Wed, Oct 31, 2018 at 7:30 AM bin.cheng <bin.ch...@linux.alibaba.com> wrote: > > > > Hi, > > In new profile probability/count infra, we have different precision quality > > categories, > > and probabilities/counts of different categories are not supposed to be > > compared or > > calculated. Though in general is an improvement, it introduces unexpected > > behavior. > > Specifically, class profile_probablity and profile_count themselves are > > implemented > > by comparing probabilities/counts against profile_count::zero(). while > > zero() is of > > profile_precision category, it's always compared different to zero of other > > precision > > categories including afdo. > > > > I can see two ways fixing this: 1) Treat zero as a common probability/count > > regardless > > of its category; 2) Provide an "is_zero" method rather than relying on "==" > > comparison > > against probability_count::zero(). 2) requires lots of code changes so I > > went with 1) > > in this patch set. This patch doesn't handle "always" but it might be. > > > > This patch also corrects a minor issue where we try to invert an > > uninitialized value. > > > > Bootstrap and test on x86_64 in patch set. Is it OK? > > I'll defer on the emit_store_flag_force change, likewise for the zero > handling in > compares - I don't think zeros of different qualities should compare equal. > Would compares against ::always() not have the very same issue? > Likewise ::even(), > ::likely(), etc.? Those always get guessed quality. Yes, these values also affected if compared with precise category, but zero is the major issue. So 2) makes more sense when checking if a profile count is_zero/is_likely/is_always etc. regardless of its categories. Once with Honza's input, I can do some experiments.
Thanks, bin > > The invert change looks OK to me. The related change to the always() API > would > suggest to replace guessed_always() with always (guessed) and also do similar > changes throughout the whole API... > > Honza? > > Thanks, > Richard. > > > > Thanks, > > bin > > > > 2018-10-31 Bin Cheng <bin.ch...@linux.alibaba.com> > > > > * expmed.c (emit_store_flag_force): Use profile_probability::always. > > * profile-count.h (profile_probability::always): Add parameter. > > (profile_probability::operator==, profile_count::operator==): Treat > > ZERO as common probability/count regardless of its quality. > > (profile_probability::invert): Don't invert uninitialized > > probability.