Fixes for profile probability sqrt() method to return correct values and avoid infinite loops
Corrects `profile_probability::sqrt()` to return the computed value and prevents infinite loops due to precision errors.
This commit addresses two issues in the sqrt() method of GCC’s profile_probability class. Firstly, it corrects the method to return the calculated result (val) instead of the input value (m_val), ensuring accurate square root computations for probability distributions. Secondly, it modifies the loop condition to prevent potential infinite loops that could occur when precision errors cause min_range to exceed max_range during calculations.
In Details
This commit corrects two bugs in the profile_probability::sqrt() method within profile-count.cc. The first bug was that the method incorrectly returned m_val (the input value) instead of val (the computed result). The second fix addresses an infinite loop condition by changing the while loop's termination condition on line 511, preventing it from occurring when min_range becomes greater than max_range due to floating-point precision issues.
- profile_probability
- A component within GCC that likely analyzes and models the probability of different execution paths or values based on profile data.
- sqrt()
- The square root function, commonly used in mathematical and statistical calculations.
- m_val
- Likely represents the 'member value' or initial input value within the
profile_probabilityclass'ssqrt()method. - val
- Likely represents the computed result or the actual value produced by the
sqrt()operation within theprofile_probabilityclass. - min_range
- The lower bound of a range of possible values.
- max_range
- The upper bound of a range of possible values.