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)
461 if (*
this ==
never ())
462 return *
this =
never ();
469 if (
m_val > other.m_val)
511 if (!(*
this ==
always ()))
512 *
this = (*
this - ret) / ret.
invert ();
572 if (*
this ==
never ())
588 if (*
this ==
never ())
602 num.quality ()), den.
quality ()));
705 void dump (FILE *f)
const;
708 void dump (
char *buffer)
const;
727 sreal to_sreal ()
const;
800#if defined (__arm__) && (__GNUC__ >= 6 && __GNUC__ <= 8)
805#define UINT64_BIT_FIELD_ALIGN __attribute__ ((aligned(8)))
807#define UINT64_BIT_FIELD_ALIGN
810#undef UINT64_BIT_FIELD_ALIGN
827 && !(other.ipa () == other))
829 if (other.ipa ().nonzero_p ()
830 && !(
ipa () == *
this))
833 return ipa_p () == other.ipa_p ();
927 return !(other < *
this);
934 if (*
this == other || !other.initialized_p ()
951 if (other ==
zero ())
953 if (*
this ==
zero ())
960 uint64_t ret_val =
m_val + other.m_val;
968 if (other ==
zero ())
970 if (*
this ==
zero ())
980 uint64_t ret_val =
m_val + other.m_val;
989 if (*
this ==
zero () || other ==
zero ())
1002 if (*
this ==
zero () || other ==
zero ())
1028 if (*
this ==
zero ())
1029 return !(other ==
zero ());
1030 if (other ==
zero ())
1033 return m_val < other.m_val;
1040 if (*
this ==
zero ())
1042 if (other ==
zero ())
1043 return !(*
this ==
zero ());
1052 return ipa ().initialized_p () &&
ipa ().m_val < (uint64_t) other;
1059 return ipa ().initialized_p () &&
ipa ().m_val > (uint64_t) other;
1066 if (*
this ==
zero ())
1068 if (other ==
zero ())
1069 return (*
this ==
zero ());
1071 return m_val <= other.m_val;
1078 if (other ==
zero ())
1080 if (*
this ==
zero ())
1081 return (other ==
zero ());
1083 return m_val >= other.m_val;
1090 return ipa ().initialized_p () &&
ipa ().m_val <= (uint64_t) other;
1097 return ipa ().initialized_p () &&
ipa ().m_val >= (uint64_t) other;
1143 if (!
a.initialized_p ())
1145 if (!
b.initialized_p ())
1208 if (*
this ==
zero ())
1231 if (num.m_quality ==
AFDO
1237 num == num.ipa () ?
GUESSED : num.m_quality);
1328 if (*
this ==
zero ()
1329 && !(overall ==
zero ()))
1350 overall.
m_val, &tmp);
1369 int to_frequency (
struct function *fun)
const;
1370 int to_cgraph_frequency (
profile_count entry_bb_count)
const;
1374 void dump (FILE *f,
struct function *fun =
NULL)
const;
1377 void debug ()
const;
gcov_type apply_scale(gcov_type freq, gcov_type scale)
Definition basic-block.h:573
Definition profile-count.h:149
enum profile_quality quality() const
Definition profile-count.h:697
profile_probability sqrt() const
Definition profile-count.cc:499
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:650
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:570
profile_probability split(const profile_probability &cprob)
Definition profile-count.h:503
static const uint32_t max_probability
Definition profile-count.h:153
profile_probability & operator/=(const profile_probability &other)
Definition profile-count.h:459
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:519
profile_probability apply_scale(profile_probability num, profile_probability den) const
Definition profile-count.h:585
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:467
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:213
void dump(FILE *f) const
Definition profile-count.cc:203
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:548
sreal to_sreal() const
Definition profile-count.cc:490
static const uint32_t uninitialized_probability
Definition profile-count.h:155
uint32_t value() const
Definition profile-count.h:694
bool probably_reliable_p() const
Definition profile-count.h:622
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:222
bool operator<(const profile_probability &other) const
Definition profile-count.h:645
bool operator<=(const profile_probability &other) const
Definition profile-count.h:655
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:249
profile_probability afdo() const
Definition profile-count.h:562
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:529
profile_probability & operator*=(const profile_probability &other)
Definition profile-count.h:418
profile_probability guessed() const
Definition profile-count.h:554
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:633
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:260
bool operator>=(const profile_probability &other) const
Definition profile-count.h:660
bool differs_lot_from_p(profile_probability other) const
Definition profile-count.cc:238
bool debug
Definition collect-utils.cc:34
uint64_t gcov_type_unsigned
Definition coretypes.h:47
#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:64
#define UINT64_BIT_FIELD_ALIGN
Definition profile-count.h:807
bool slow_safe_scale_64bit(uint64_t a, uint64_t b, uint64_t c, uint64_t *res)
Definition profile-count.cc:278
const char * profile_quality_as_string(enum profile_quality)
Definition profile-count.cc:56
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:669
Definition lto-streamer.h:745
Definition profile-count.h:789
profile_count combine_with_ipa_count(profile_count ipa)
Definition profile-count.cc:402
profile_count apply_probability(profile_probability prob) const
Definition profile-count.h:1172
uint64_t value() const
Definition profile-count.h:913
sreal to_sreal_scale(profile_count in, bool *known=NULL) const
Definition profile-count.cc:334
static const uint64_t uninitialized_count
Definition profile-count.h:798
profile_count force_nonzero() const
Definition profile-count.cc:578
gcov_type to_gcov_type() const
Definition profile-count.h:882
bool operator<(const profile_count &other) const
Definition profile-count.h:1024
profile_count global0adjusted() const
Definition profile-count.h:1275
static const int n_bits
Definition profile-count.h:795
uint64_t UINT64_BIT_FIELD_ALIGN m_val
Definition profile-count.h:809
bool operator<=(const profile_count &other) const
Definition profile-count.h:1062
static profile_count stream_in(class lto_input_block *)
Definition profile-count.cc:146
static const uint64_t max_count
Definition profile-count.h:796
profile_count operator/(int64_t den) const
Definition profile-count.h:1114
profile_count force_guessed() const
Definition profile-count.h:1293
profile_count combine_with_ipa_count_within(profile_count ipa, profile_count ipa2)
Definition profile-count.cc:421
profile_count operator+(const profile_count &other) const
Definition profile-count.h:949
bool initialized_p() const
Definition profile-count.h:889
enum profile_quality quality() const
Definition profile-count.h:916
void dump(FILE *f, struct function *fun=NULL) const
Definition profile-count.cc:94
int to_cgraph_frequency(profile_count entry_bb_count) const
Definition profile-count.cc:316
static profile_count uninitialized()
Definition profile-count.h:873
static profile_count afdo_zero()
Definition profile-count.h:850
bool very_large_p()
Definition profile-count.h:1362
bool precise_p() const
Definition profile-count.h:907
static profile_count one()
Definition profile-count.h:866
enum profile_quality m_quality
Definition profile-count.h:811
static void adjust_for_ipa_scaling(profile_count *num, profile_count *den)
Definition profile-count.cc:373
static profile_count zero()
Definition profile-count.h:837
profile_count & operator+=(const profile_count &other)
Definition profile-count.h:966
bool reliable_p() const
Definition profile-count.h:895
profile_count guessed_local() const
Definition profile-count.h:1243
bool operator>(const profile_count &other) const
Definition profile-count.h:1036
profile_count operator*=(int64_t num)
Definition profile-count.h:1105
profile_count apply_scale(profile_count num, profile_count den) const
Definition profile-count.h:1206
profile_count global0afdo() const
Definition profile-count.h:1264
profile_count operator*(int64_t num) const
Definition profile-count.h:1100
bool ok_for_merging(profile_count other) const
Definition profile-count.h:922
profile_count merge(profile_count other) const
Definition profile-count.h:932
static profile_count guessed_zero()
Definition profile-count.h:858
profile_count ipa() const
Definition profile-count.h:1303
static profile_count from_gcov_type(gcov_type v, profile_quality quality=PRECISE)
Definition profile-count.cc:449
bool nonzero_p() const
Definition profile-count.h:1128
bool compatible_p(const profile_count other) const
Definition profile-count.h:817
bool differs_from_p(profile_count other) const
Definition profile-count.cc:128
bool operator==(const profile_count &other) const
Definition profile-count.h:944
bool operator>=(const profile_count &other) const
Definition profile-count.h:1074
profile_probability probability_in(const profile_count overall) const
Definition profile-count.h:1326
static profile_count adjusted_zero()
Definition profile-count.h:842
void stream_out(struct output_block *)
Definition profile-count.cc:157
profile_count global0() const
Definition profile-count.h:1253
profile_count apply_scale(int64_t num, int64_t den) const
Definition profile-count.h:1190
profile_count operator-(const profile_count &other) const
Definition profile-count.h:987
static profile_count max_prefer_initialized(const profile_count a, const profile_count b)
Definition profile-count.h:1141
profile_count afdo() const
Definition profile-count.h:1317
profile_count & operator-=(const profile_count &other)
Definition profile-count.h:1000
void debug() const
Definition profile-count.cc:119
int to_frequency(struct function *fun) const
Definition profile-count.cc:297
bool ipa_p() const
Definition profile-count.h:901
profile_count guessed() const
Definition profile-count.h:1285
bool verify() const
Definition profile-count.h:1016
profile_count operator/=(int64_t den)
Definition profile-count.h:1119
profile_count apply_probability(int prob) const
Definition profile-count.h:1156
#define NULL
Definition system.h:58
#define INTTYPE_MAXIMUM(t)
Definition system.h:351
#define MIN(X, Y)
Definition system.h:410
#define gcc_checking_assert(EXPR)
Definition system.h:835
#define MAX(X, Y)
Definition system.h:411
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