public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] profile-count: fix /= and *= operators
@ 2022-06-24  8:13 Martin Liška
  2022-06-24  8:38 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2022-06-24  8:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka

Hi.

As noticed in the PR, I wrongly introduced /= and *= operators.
Problem was that these operators need to modify *this object.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

	PR middle-end/106059

gcc/ChangeLog:

	* profile-count.h: *= and /= operators need to modify this
	object.
---
 gcc/profile-count.h | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/gcc/profile-count.h b/gcc/profile-count.h
index be6e2d57cf7..141a8827001 100644
--- a/gcc/profile-count.h
+++ b/gcc/profile-count.h
@@ -605,9 +605,10 @@ public:
       return apply_scale (num, 1);
     }
 
-  profile_probability operator*= (int64_t den) const
+  profile_probability operator*= (int64_t num)
     {
-      return *this * den;
+      *this = apply_scale (num, 1);
+      return *this;
     }
 
   profile_probability operator/ (int64_t den) const
@@ -615,9 +616,10 @@ public:
       return apply_scale (1, den);
     }
 
-  profile_probability operator/= (int64_t den) const
+  profile_probability operator/= (int64_t den)
     {
-      return *this / den;
+      *this = apply_scale (1, den);
+      return *this;
     }
 
   /* Get the value of the count.  */
@@ -1017,9 +1019,10 @@ public:
       return apply_scale (num, 1);
     }
 
-  profile_count operator*= (int64_t den) const
+  profile_count operator*= (int64_t num)
     {
-      return *this * den;
+      *this = apply_scale (num, 1);
+      return *this;
     }
 
   profile_count operator/ (int64_t den) const
@@ -1027,9 +1030,10 @@ public:
       return apply_scale (1, den);
     }
 
-  profile_count operator/= (int64_t den) const
+  profile_count operator/= (int64_t den)
     {
-      return *this / den;
+      *this = apply_scale (1, den);
+      return *this;
     }
 
   /* Return true when value is not zero and can be used for scaling. 
-- 
2.36.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] profile-count: fix /= and *= operators
  2022-06-24  8:13 [PATCH] profile-count: fix /= and *= operators Martin Liška
@ 2022-06-24  8:38 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-06-24  8:38 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches, Jan Hubicka



> Am 24.06.2022 um 10:14 schrieb Martin Liška <mliska@suse.cz>:
> 
> Hi.
> 
> As noticed in the PR, I wrongly introduced /= and *= operators.
> Problem was that these operators need to modify *this object.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?

Ok
> Thanks,
> Martin
> 
>    PR middle-end/106059
> 
> gcc/ChangeLog:
> 
>    * profile-count.h: *= and /= operators need to modify this
>    object.
> ---
> gcc/profile-count.h | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/gcc/profile-count.h b/gcc/profile-count.h
> index be6e2d57cf7..141a8827001 100644
> --- a/gcc/profile-count.h
> +++ b/gcc/profile-count.h
> @@ -605,9 +605,10 @@ public:
>       return apply_scale (num, 1);
>     }
> 
> -  profile_probability operator*= (int64_t den) const
> +  profile_probability operator*= (int64_t num)
>     {
> -      return *this * den;
> +      *this = apply_scale (num, 1);
> +      return *this;
>     }
> 
>   profile_probability operator/ (int64_t den) const
> @@ -615,9 +616,10 @@ public:
>       return apply_scale (1, den);
>     }
> 
> -  profile_probability operator/= (int64_t den) const
> +  profile_probability operator/= (int64_t den)
>     {
> -      return *this / den;
> +      *this = apply_scale (1, den);
> +      return *this;
>     }
> 
>   /* Get the value of the count.  */
> @@ -1017,9 +1019,10 @@ public:
>       return apply_scale (num, 1);
>     }
> 
> -  profile_count operator*= (int64_t den) const
> +  profile_count operator*= (int64_t num)
>     {
> -      return *this * den;
> +      *this = apply_scale (num, 1);
> +      return *this;
>     }
> 
>   profile_count operator/ (int64_t den) const
> @@ -1027,9 +1030,10 @@ public:
>       return apply_scale (1, den);
>     }
> 
> -  profile_count operator/= (int64_t den) const
> +  profile_count operator/= (int64_t den)
>     {
> -      return *this / den;
> +      *this = apply_scale (1, den);
> +      return *this;
>     }
> 
>   /* Return true when value is not zero and can be used for scaling. 
> -- 
> 2.36.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-24  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24  8:13 [PATCH] profile-count: fix /= and *= operators Martin Liška
2022-06-24  8:38 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).