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;
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 ())
463 if (*
this ==
never ())
464 return *
this =
never ();
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))
811 && !(
ipa () == *
this))
908 return !(other < *
this);
932 if (other ==
zero ())
934 if (*
this ==
zero ())
949 if (other ==
zero ())
951 if (*
this ==
zero ())
970 if (*
this ==
zero () || other ==
zero ())
983 if (*
this ==
zero () || other ==
zero ())
1009 if (*
this ==
zero ())
1010 return !(other ==
zero ());
1011 if (other ==
zero ())
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 ());
1059 if (other ==
zero ())
1061 if (*
this ==
zero ())
1062 return (other ==
zero ());
1071 return ipa ().initialized_p () &&
ipa ().m_val <= (uint64_t) other;
1078 return ipa ().initialized_p () &&
ipa ().m_val >= (uint64_t) other;
1136 other = other.
ipa ();
1142 if (*
this ==
zero ())
1144 if (other ==
zero ())
1207 if (*
this ==
zero ())
1317 if (*
this ==
zero ()
1318 && !(overall ==
zero ()))
1352 int to_frequency (
struct function *fun)
const;
1353 int to_cgraph_frequency (
profile_count entry_bb_count)
const;
1357 void dump (FILE *f,
struct function *fun =
NULL)
const;
1360 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:497
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:465
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:211
void dump(FILE *f) const
Definition profile-count.cc:201
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:488
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:220
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:247
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:527
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:258
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:236
bool debug
Definition collect-utils.cc:34
#define GTY(x)
Definition coretypes.h:41
int64_t gcov_type
Definition coretypes.h:46
bool operator==(const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
Definition diagnostic-spec.h:131
double pow(double, double)
bool operator<(const pattern_pos &e1, const pattern_pos &e2)
Definition genrecog.cc:3893
@ value
Definition logical-location.h:59
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:62
#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:276
const char * profile_quality_as_string(enum profile_quality)
Definition profile-count.cc:54
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:400
profile_count apply_probability(profile_probability prob) const
Definition profile-count.h:1171
uint64_t value() const
Definition profile-count.h:894
sreal to_sreal_scale(profile_count in, bool *known=NULL) const
Definition profile-count.cc:332
static const uint64_t uninitialized_count
Definition profile-count.h:779
profile_count force_nonzero() const
Definition profile-count.h:1115
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:1264
static const int n_bits
Definition profile-count.h:776
profile_count max(profile_count other) const
Definition profile-count.h:1128
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:144
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:1282
profile_count combine_with_ipa_count_within(profile_count ipa, profile_count ipa2)
Definition profile-count.cc:419
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:92
int to_cgraph_frequency(profile_count entry_bb_count) const
Definition profile-count.cc:314
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:1345
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:371
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:1232
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:1205
profile_count global0afdo() const
Definition profile-count.h:1253
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:1292
static profile_count from_gcov_type(gcov_type v, profile_quality quality=PRECISE)
Definition profile-count.cc:447
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:126
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:1315
static profile_count adjusted_zero()
Definition profile-count.h:823
void stream_out(struct output_block *)
Definition profile-count.cc:155
profile_count global0() const
Definition profile-count.h:1242
profile_count apply_scale(int64_t num, int64_t den) const
Definition profile-count.h:1189
profile_count operator-(const profile_count &other) const
Definition profile-count.h:968
profile_count afdo() const
Definition profile-count.h:1306
profile_count & operator-=(const profile_count &other)
Definition profile-count.h:981
void debug() const
Definition profile-count.cc:117
int to_frequency(struct function *fun) const
Definition profile-count.cc:295
bool ipa_p() const
Definition profile-count.h:882
profile_count guessed() const
Definition profile-count.h:1274
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:1155
#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:269
comp_cost operator-(comp_cost cost1, comp_cost cost2)
Definition tree-ssa-loop-ivopts.cc:282