aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgloop.cc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2023-07-21 16:44:01 +0200
committerJan Hubicka <jh@suse.cz>2023-07-21 16:44:01 +0200
commite35d297fc9a625f11d861b6feacb228810e4e6bd (patch)
treecff62b168fc72eb4b5ff88c7b50b2362b02dd807 /gcc/cfgloop.cc
parent65ff4a45b11b5ab13ef849bd5721ab28ff316202 (diff)
downloadgcc-e35d297fc9a625f11d861b6feacb228810e4e6bd.zip
gcc-e35d297fc9a625f11d861b6feacb228810e4e6bd.tar.gz
gcc-e35d297fc9a625f11d861b6feacb228810e4e6bd.tar.bz2
Fix sreal::to_int and implement sreal::to_nearest_int
while exploring new loop estimate dumps, I noticed that loop iterating 1.8 times by profile is etimated as iterating once instead of 2 by nb_estimate. While nb_estimate should really be a sreal and I will convert it incrementally, I found problem is in previous patch doing: + *nit = (snit + 0.5).to_int (); this does not work for sreal because it has only constructor from integer, so first 0.5 is rounded to 0 and then added to snit. Some code uses sreal(1, -1) which produces 0.5, but it reuqires unnecessary addition, so I decided to add to_nearest_int. Testing it I noticed that to_int is buggy: (sreal(3)/2).to_int () == 1 while (sreal(-3)/2).to_int () == -2 Fix is easy, we need to correctly shift in positive values. This patch fixes it and adds the to_nearest_int alternative. gcc/ChangeLog: * sreal.cc (sreal::to_nearest_int): New. (sreal_verify_basics): Verify also to_nearest_int. (verify_aritmetics): Likewise. (sreal_verify_conversions): New. (sreal_cc_tests): Call sreal_verify_conversions. * sreal.h: (sreal::to_nearest_int): Declare
Diffstat (limited to 'gcc/cfgloop.cc')
0 files changed, 0 insertions, 0 deletions