diff mbox series

[4/4] Fix scaling of a sreal number.

Message ID 49d125d60e220ad2cc5fa83af0a56e3d1522b8f5.1537774329.git.mliska@suse.cz
State New
Headers show
Series Clean-up warnings spotted by Rtags | expand

Commit Message

Martin Liška Sept. 23, 2018, 7:08 a.m. UTC
The patch is addressing following LLVM warning:
gcc/ipa-fnsummary.c:2745:54:Value Conversion Issue: implicit conversion from 'double' to 'int64_t' (aka 'long') changes value from 0.99 to 0: -Wliteral-conversion

Taking look at GIMPLE IR we end up with:

  <bb 45> :
  D.107433 ={v} {CLOBBER};
  sreal::sreal (&D.107437, -1, 0);
  sreal::sreal (&D.107434, 0, 0);
  D.107435 = sreal::operator* (&time, &D.107434);
  D.107436 = sreal::operator- (&nonspecialized_time, &D.107435);
  _65 = operator>= (&D.107436, &D.107437);
  _66 = ~_65;
  if (_66 != 0)
    goto <bb 46>; [INV]
  else
    goto <bb 47>; [INV]

  <bb 46> :
  fancy_abort ("/home/marxin/Programming/gcc/gcc/ipa-fnsummary.c", 2745, &__FUNCTION__);

which confirms the warning.

gcc/ChangeLog:

2018-09-23  Martin Liska  <mliska@suse.cz>

	* ipa-fnsummary.c (estimate_node_size_and_time): Scale by two
	integers and not by a float value.
---
 gcc/ipa-fnsummary.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeff Law Sept. 24, 2018, 2:39 p.m. UTC | #1
On 9/23/18 1:08 AM, marxin wrote:
> 
> The patch is addressing following LLVM warning:
> gcc/ipa-fnsummary.c:2745:54:Value Conversion Issue: implicit conversion from 'double' to 'int64_t' (aka 'long') changes value from 0.99 to 0: -Wliteral-conversion
> 
> Taking look at GIMPLE IR we end up with:
> 
>   <bb 45> :
>   D.107433 ={v} {CLOBBER};
>   sreal::sreal (&D.107437, -1, 0);
>   sreal::sreal (&D.107434, 0, 0);
>   D.107435 = sreal::operator* (&time, &D.107434);
>   D.107436 = sreal::operator- (&nonspecialized_time, &D.107435);
>   _65 = operator>= (&D.107436, &D.107437);
>   _66 = ~_65;
>   if (_66 != 0)
>     goto <bb 46>; [INV]
>   else
>     goto <bb 47>; [INV]
> 
>   <bb 46> :
>   fancy_abort ("/home/marxin/Programming/gcc/gcc/ipa-fnsummary.c", 2745, &__FUNCTION__);
> 
> which confirms the warning.
> 
> gcc/ChangeLog:
> 
> 2018-09-23  Martin Liska  <mliska@suse.cz>
> 
> 	* ipa-fnsummary.c (estimate_node_size_and_time): Scale by two
> 	integers and not by a float value.
OK.
jeff
diff mbox series

Patch

diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index 62095c6cf6f..9cb7d41ccc5 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -2742,7 +2742,7 @@  estimate_node_size_and_time (struct cgraph_node *node,
   gcc_checking_assert (time >= 0);
   /* nonspecialized_time should be always bigger than specialized time.
      Roundoff issues however may get into the way.  */
-  gcc_checking_assert ((nonspecialized_time - time * 0.99) >= -1);
+  gcc_checking_assert ((nonspecialized_time - time * 99 / 100) >= -1);
 
   /* Roundoff issues may make specialized time bigger than nonspecialized
      time.  We do not really want that to happen because some heurstics