diff options
author | Jan Hubicka <jh@suse.cz> | 2023-07-21 16:50:49 +0200 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2023-07-21 16:51:46 +0200 |
commit | feeee84079ee165f13f9fb8cdcf5dcea98d394e0 (patch) | |
tree | b1690f1a312f0b3b6186dd732d815e0b1d9115d0 /gcc | |
parent | fc92f5811e77b091d65045f2daa0f83c31d00797 (diff) | |
download | gcc-feeee84079ee165f13f9fb8cdcf5dcea98d394e0.zip gcc-feeee84079ee165f13f9fb8cdcf5dcea98d394e0.tar.gz gcc-feeee84079ee165f13f9fb8cdcf5dcea98d394e0.tar.bz2 |
Use sreal::nearest_int
Fix conversions from sreal to nearest integer.
gcc/ChangeLog:
* cfgloop.cc (get_estimated_loop_iterations): Use sreal::to_nearest_int
* cfgloopanal.cc (expected_loop_iterations_unbounded): Likewise.
* predict.cc (estimate_bb_frequencies): Likewise.
* profile.cc (branch_prob): Likewise.
* tree-ssa-loop-niter.cc (estimate_numbers_of_iterations): Likewise
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cfgloop.cc | 2 | ||||
-rw-r--r-- | gcc/cfgloopanal.cc | 2 | ||||
-rw-r--r-- | gcc/predict.cc | 4 | ||||
-rw-r--r-- | gcc/profile.cc | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-niter.cc | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc index 9ca85e6..6d46b5b 100644 --- a/gcc/cfgloop.cc +++ b/gcc/cfgloop.cc @@ -2012,7 +2012,7 @@ get_estimated_loop_iterations (class loop *loop, widest_int *nit) if (expected_loop_iterations_by_profile (loop, &snit, &reliable) && reliable) { - *nit = (snit + 0.5).to_int (); + *nit = snit.to_nearest_int (); return true; } return false; diff --git a/gcc/cfgloopanal.cc b/gcc/cfgloopanal.cc index 2bf2eb0..c86a537 100644 --- a/gcc/cfgloopanal.cc +++ b/gcc/cfgloopanal.cc @@ -321,7 +321,7 @@ expected_loop_iterations_unbounded (const class loop *loop, sreal sreal_expected; if (expected_loop_iterations_by_profile (loop, &sreal_expected, read_profile_p)) - expected = (sreal_expected + 0.5).to_int (); + expected = sreal_expected.to_nearest_int (); else expected = param_avg_loop_niter; diff --git a/gcc/predict.cc b/gcc/predict.cc index 8f44f5b..6777e6c 100644 --- a/gcc/predict.cc +++ b/gcc/predict.cc @@ -4003,8 +4003,8 @@ estimate_bb_frequencies () break; } } - tmp = tmp * freq_max + sreal (1, -1); - profile_count count = profile_count::from_gcov_type (tmp.to_int ()); + tmp = tmp * freq_max; + profile_count count = profile_count::from_gcov_type (tmp.to_nearest_int ()); /* If we have profile feedback in which this function was never executed, then preserve this info. */ diff --git a/gcc/profile.cc b/gcc/profile.cc index 84d47b3..fc59326 100644 --- a/gcc/profile.cc +++ b/gcc/profile.cc @@ -1553,7 +1553,7 @@ branch_prob (bool thunk) && expected_loop_iterations_by_profile (loop, &nit, &reliable) && reliable) { - widest_int bound = (nit + 0.5).to_int (); + widest_int bound = nit.to_nearest_int (); loop->any_estimate = false; record_niter_bound (loop, bound, true, false); } diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index a806801..705bcc0 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -4801,7 +4801,7 @@ estimate_numbers_of_iterations (class loop *loop) && expected_loop_iterations_by_profile (loop, &nit, &reliable) && reliable) { - bound = (nit + 0.5).to_int (); + bound = nit.to_nearest_int (); record_niter_bound (loop, bound, true, false); } |