21#ifndef GCC_PROFILE_COUNT_H
22#define GCC_PROFILE_COUNT_H
75#define REG_BR_PROB_BASE 10000
77#define RDIV(X,Y) (((X) + (Y) / 2) / (Y))
86#if (GCC_VERSION >= 5000)
88 if (!__builtin_mul_overflow (
a,
b, &tmp)
89 && !__builtin_add_overflow (tmp, c/2, &tmp))
100 if (
a < ((uint64_t)1 << 31)
101 &&
b < ((uint64_t)1 << 31)
102 && c < ((uint64_t)1 << 31))
104 *res = (
a *
b + (c / 2)) / c;
155 = ((uint32_t) 1 << (
n_bits - 1)) - 1;
305 ret.
m_val = ((
unsigned int)v) / 8;
340 return m_val == other.m_val &&
quality () == other.quality ();
345 if (other ==
never ())
347 if (*
this ==
never ())
360 if (other ==
never ())
362 if (*
this ==
never ())
379 if (*
this ==
never ()
380 || other ==
never ())
392 if (*
this ==
never ()
393 || other ==
never ())
407 if (*
this ==
never ()
408 || other ==
never ())
420 if (*
this ==
never ()
421 || other ==
never ())
422 return *
this =
never ();
435 if (*
this ==
never ())
441 if (
m_val >= other.m_val)
463 if (*
this ==
never ())
464 return *
this =
never ();
471 if (
m_val > other.m_val)
515 if (!(*
this ==
always ()))
516 *
this = (*
this - ret) / ret.
invert ();
552 if (*
this ==
never ())
568 if (*
this ==
never ())
686 void dump (FILE *f)
const;
689 void dump (
char *buffer)
const;
708 sreal to_sreal ()
const;
781#if defined (__arm__) && (__GNUC__ >= 6 && __GNUC__ <= 8)
786#define UINT64_BIT_FIELD_ALIGN __attribute__ ((aligned(8)))
788#define UINT64_BIT_FIELD_ALIGN
791#undef UINT64_BIT_FIELD_ALIGN
808 && !(other.ipa () == other))
810 if (other.ipa ().nonzero_p ()
811 && !(
ipa () == *
this))
814 return ipa_p () == other.ipa_p ();
908 return !(other < *
this);
915 if (*
this == other || !other.initialized_p ()
932 if (other ==
zero ())
934 if (*
this ==
zero ())
941 uint64_t ret_val =
m_val + other.m_val;
949 if (other ==
zero ())
951 if (*
this ==
zero ())
961 uint64_t ret_val =
m_val + other.m_val;
970 if (*
this ==
zero () || other ==
zero ())
983 if (*
this ==
zero () || other ==
zero ())
1009 if (*
this ==
zero ())
1010 return !(other ==
zero ());
1011 if (other ==
zero ())
1014 return m_val < other.m_val;
1021 if (*
this ==
zero ())
1023 if (other ==
zero ())
1024 return !(*
this ==
zero ());
1033 return ipa ().initialized_p () &&
ipa ().m_val < (uint64_t) other;
1040 return ipa ().initialized_p () &&
ipa ().m_val > (uint64_t) other;
1047 if (*
this ==
zero ())
1049 if (other ==
zero ())
1050 return (*
this ==
zero ());
1052 return m_val <= other.m_val;
1059 if (other ==
zero ())
1061 if (*
this ==
zero ())
1062 return (other ==
zero ());
1064 return m_val >= other.m_val;
1071 return ipa ().initialized_p () &&
ipa ().m_val <= (uint64_t) other;
1078 return ipa ().initialized_p () &&
ipa ().m_val >= (uint64_t) other;
1125 other = other.ipa ();
1129 if (!other.initialized_p ())
1131 if (*
this ==
zero ())
1133 if (other ==
zero ())
1136 if (val.
m_val < other.m_val || (
m_val == other.m_val
1196 if (*
this ==
zero ())
1316 if (*
this ==
zero ()
1317 && !(overall ==
zero ()))
1351 int to_frequency (
struct function *fun)
const;
1352 int to_cgraph_frequency (
profile_count entry_bb_count)
const;
1356 void dump (FILE *f,
struct function *fun =
NULL)
const;
1359 void debug ()
const;
gcov_type apply_scale(gcov_type freq, gcov_type scale)
Definition basic-block.h:578
Definition profile-count.h:149
enum profile_quality quality() const
Definition profile-count.h:678
profile_probability sqrt() const
Definition profile-count.cc:498
profile_probability()
Definition profile-count.h:176
static const int n_bits
Definition profile-count.h:150
static profile_probability unlikely()
Definition profile-count.h:208
bool operator>(const profile_probability &other) const
Definition profile-count.h:631
static const int min_quality
Definition profile-count.h:159
profile_probability operator+(const profile_probability &other) const
Definition profile-count.h:343
bool reliable_p() const
Definition profile-count.h:269
friend struct profile_count
Definition profile-count.h:164
profile_probability apply_scale(int64_t num, int64_t den) const
Definition profile-count.h:550
profile_probability split(const profile_probability &cprob)
Definition profile-count.h:507
static const uint32_t max_probability
Definition profile-count.h:153
profile_probability & operator/=(const profile_probability &other)
Definition profile-count.h:461
profile_probability operator*(const profile_probability &other) const
Definition profile-count.h:405
void set_quality(profile_quality quality)
Definition profile-count.h:168
gcov_type apply(gcov_type val) const
Definition profile-count.h:520
profile_probability apply_scale(profile_probability num, profile_probability den) const
Definition profile-count.h:565
static profile_probability uninitialized()
Definition profile-count.h:254
static profile_probability very_unlikely()
Definition profile-count.h:200
profile_probability combine_with_count(profile_count count1, profile_probability other, profile_count count2) const
Definition profile-count.cc:466
uint32_t m_val
Definition profile-count.h:161
int to_reg_br_prob_base() const
Definition profile-count.h:295
static profile_probability guessed_never()
Definition profile-count.h:192
void debug() const
Definition profile-count.cc:212
void dump(FILE *f) const
Definition profile-count.cc:202
bool operator==(const profile_probability &other) const
Definition profile-count.h:338
bool initialized_p() const
Definition profile-count.h:263
profile_probability operator/(const profile_probability &other) const
Definition profile-count.h:433
profile_probability(uint32_t val, profile_quality quality)
Definition profile-count.h:179
profile_probability invert() const
Definition profile-count.h:528
sreal to_sreal() const
Definition profile-count.cc:489
static const uint32_t uninitialized_probability
Definition profile-count.h:155
uint32_t value() const
Definition profile-count.h:675
bool probably_reliable_p() const
Definition profile-count.h:603
static profile_probability from_reg_br_prob_base(int v)
Definition profile-count.h:276
bool differs_from_p(profile_probability other) const
Definition profile-count.cc:221
bool operator<(const profile_probability &other) const
Definition profile-count.h:626
bool operator<=(const profile_probability &other) const
Definition profile-count.h:636
int to_reg_br_prob_note() const
Definition profile-count.h:310
static profile_probability stream_in(class lto_input_block *)
Definition profile-count.cc:248
profile_probability afdo() const
Definition profile-count.h:542
profile_probability & operator+=(const profile_probability &other)
Definition profile-count.h:358
profile_probability adjusted() const
Definition profile-count.h:286
profile_probability operator-(const profile_probability &other) const
Definition profile-count.h:377
profile_probability pow(int) const
Definition profile-count.cc:528
profile_probability & operator*=(const profile_probability &other)
Definition profile-count.h:418
profile_probability guessed() const
Definition profile-count.h:534
profile_probability & operator-=(const profile_probability &other)
Definition profile-count.h:390
static profile_probability from_reg_br_prob_note(int v)
Definition profile-count.h:302
static profile_probability very_likely()
Definition profile-count.h:221
bool verify() const
Definition profile-count.h:614
static profile_probability probability_in_gcov_type(gcov_type val1, gcov_type val2)
Definition profile-count.h:320
static profile_probability likely()
Definition profile-count.h:226
static profile_probability guessed_always()
Definition profile-count.h:236
static profile_probability always()
Definition profile-count.h:244
unsigned m_adjusted_quality
Definition profile-count.h:162
bool nonzero_p() const
Definition profile-count.h:231
static profile_probability never()
Definition profile-count.h:184
static profile_probability even()
Definition profile-count.h:216
void stream_out(struct output_block *)
Definition profile-count.cc:259
bool operator>=(const profile_probability &other) const
Definition profile-count.h:641
bool differs_lot_from_p(profile_probability other) const
Definition profile-count.cc:237
bool debug
Definition collect-utils.cc:34
#define GTY(x)
Definition coretypes.h:41
int64_t gcov_type
Definition coretypes.h:46
static bool operator==(cfa_reg &cfa, rtx reg)
Definition dwarf2cfi.cc:1164
double pow(double, double)
bool operator<(const pattern_pos &e1, const pattern_pos &e2)
Definition genrecog.cc:3893
poly_int< N, C > r
Definition poly-int.h:774
Ca const poly_int< N, Cb > & b
Definition poly-int.h:771
Ca & a
Definition poly-int.h:770
profile_quality
Definition profile-count.h:30
@ ADJUSTED
Definition profile-count.h:63
@ GUESSED_LOCAL
Definition profile-count.h:38
@ UNINITIALIZED_PROFILE
Definition profile-count.h:32
@ GUESSED_GLOBAL0_AFDO
Definition profile-count.h:41
@ GUESSED_GLOBAL0_ADJUSTED
Definition profile-count.h:44
@ GUESSED_GLOBAL0
Definition profile-count.h:49
@ AFDO
Definition profile-count.h:58
@ PRECISE
Definition profile-count.h:67
@ GUESSED
Definition profile-count.h:55
#define RDIV(X, Y)
Definition profile-count.h:77
#define REG_BR_PROB_BASE
Definition profile-count.h:75
bool parse_profile_quality(const char *value, profile_quality *quality)
Definition profile-count.cc:63
#define UINT64_BIT_FIELD_ALIGN
Definition profile-count.h:788
bool slow_safe_scale_64bit(uint64_t a, uint64_t b, uint64_t c, uint64_t *res)
Definition profile-count.cc:277
const char * profile_quality_as_string(enum profile_quality)
Definition profile-count.cc:55
bool safe_scale_64bit(uint64_t a, uint64_t b, uint64_t c, uint64_t *res)
Definition profile-count.h:84
sreal & operator/=(sreal &a, const sreal &b)
Definition sreal.h:157
bool operator<=(const sreal &a, const sreal &b)
Definition sreal.h:177
sreal & operator*=(sreal &a, const sreal &b)
Definition sreal.h:162
bool operator>(const sreal &a, const sreal &b)
Definition sreal.h:172
sreal & operator-=(sreal &a, const sreal &b)
Definition sreal.h:152
sreal & operator+=(sreal &a, const sreal &b)
Definition sreal.h:147
bool operator>=(const sreal &a, const sreal &b)
Definition sreal.h:182
Definition function.h:249
Definition lto-streamer.h:633
Definition lto-streamer.h:709
Definition profile-count.h:770
profile_count combine_with_ipa_count(profile_count ipa)
Definition profile-count.cc:401
profile_count apply_probability(profile_probability prob) const
Definition profile-count.h:1160
uint64_t value() const
Definition profile-count.h:894
sreal to_sreal_scale(profile_count in, bool *known=NULL) const
Definition profile-count.cc:333
static const uint64_t uninitialized_count
Definition profile-count.h:779
profile_count force_nonzero() const
Definition profile-count.cc:577
gcov_type to_gcov_type() const
Definition profile-count.h:863
bool operator<(const profile_count &other) const
Definition profile-count.h:1005
profile_count global0adjusted() const
Definition profile-count.h:1263
static const int n_bits
Definition profile-count.h:776
profile_count max(profile_count other) const
Definition profile-count.h:1117
uint64_t UINT64_BIT_FIELD_ALIGN m_val
Definition profile-count.h:790
bool operator<=(const profile_count &other) const
Definition profile-count.h:1043
static profile_count stream_in(class lto_input_block *)
Definition profile-count.cc:145
static const uint64_t max_count
Definition profile-count.h:777
profile_count operator/(int64_t den) const
Definition profile-count.h:1095
profile_count force_guessed() const
Definition profile-count.h:1281
profile_count combine_with_ipa_count_within(profile_count ipa, profile_count ipa2)
Definition profile-count.cc:420
profile_count operator+(const profile_count &other) const
Definition profile-count.h:930
bool initialized_p() const
Definition profile-count.h:870
enum profile_quality quality() const
Definition profile-count.h:897
void dump(FILE *f, struct function *fun=NULL) const
Definition profile-count.cc:93
int to_cgraph_frequency(profile_count entry_bb_count) const
Definition profile-count.cc:315
static profile_count uninitialized()
Definition profile-count.h:854
static profile_count afdo_zero()
Definition profile-count.h:831
bool very_large_p()
Definition profile-count.h:1344
bool precise_p() const
Definition profile-count.h:888
static profile_count one()
Definition profile-count.h:847
enum profile_quality m_quality
Definition profile-count.h:792
static void adjust_for_ipa_scaling(profile_count *num, profile_count *den)
Definition profile-count.cc:372
static profile_count zero()
Definition profile-count.h:818
profile_count & operator+=(const profile_count &other)
Definition profile-count.h:947
bool reliable_p() const
Definition profile-count.h:876
profile_count guessed_local() const
Definition profile-count.h:1231
bool operator>(const profile_count &other) const
Definition profile-count.h:1017
profile_count operator*=(int64_t num)
Definition profile-count.h:1086
profile_count apply_scale(profile_count num, profile_count den) const
Definition profile-count.h:1194
profile_count global0afdo() const
Definition profile-count.h:1252
profile_count operator*(int64_t num) const
Definition profile-count.h:1081
bool ok_for_merging(profile_count other) const
Definition profile-count.h:903
profile_count merge(profile_count other) const
Definition profile-count.h:913
static profile_count guessed_zero()
Definition profile-count.h:839
profile_count ipa() const
Definition profile-count.h:1291
static profile_count from_gcov_type(gcov_type v, profile_quality quality=PRECISE)
Definition profile-count.cc:448
bool nonzero_p() const
Definition profile-count.h:1109
bool compatible_p(const profile_count other) const
Definition profile-count.h:798
bool differs_from_p(profile_count other) const
Definition profile-count.cc:127
bool operator==(const profile_count &other) const
Definition profile-count.h:925
bool operator>=(const profile_count &other) const
Definition profile-count.h:1055
profile_probability probability_in(const profile_count overall) const
Definition profile-count.h:1314
static profile_count adjusted_zero()
Definition profile-count.h:823
void stream_out(struct output_block *)
Definition profile-count.cc:156
profile_count global0() const
Definition profile-count.h:1241
profile_count apply_scale(int64_t num, int64_t den) const
Definition profile-count.h:1178
profile_count operator-(const profile_count &other) const
Definition profile-count.h:968
profile_count afdo() const
Definition profile-count.h:1305
profile_count & operator-=(const profile_count &other)
Definition profile-count.h:981
void debug() const
Definition profile-count.cc:118
int to_frequency(struct function *fun) const
Definition profile-count.cc:296
bool ipa_p() const
Definition profile-count.h:882
profile_count guessed() const
Definition profile-count.h:1273
bool verify() const
Definition profile-count.h:997
profile_count operator/=(int64_t den)
Definition profile-count.h:1100
profile_count apply_probability(int prob) const
Definition profile-count.h:1144
#define NULL
Definition system.h:50
#define MIN(X, Y)
Definition system.h:396
#define gcc_checking_assert(EXPR)
Definition system.h:821
#define MAX(X, Y)
Definition system.h:397
comp_cost operator+(comp_cost cost1, comp_cost cost2)
Definition tree-ssa-loop-ivopts.cc:270
comp_cost operator-(comp_cost cost1, comp_cost cost2)
Definition tree-ssa-loop-ivopts.cc:283