public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix real_2expN mode arguments in fixed-value.c
@ 2015-10-29 15:30 Richard Sandiford
  2015-10-29 15:47 ` Bernd Schmidt
  2015-10-29 16:23 ` Richard Biener
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Sandiford @ 2015-10-29 15:30 UTC (permalink / raw)
  To: gcc-patches

fixed-value.c was passing a fixed-point mode to the floating-point
real_2expN routine.  That didn't cause a problem in practice because
all real_2expN did was check for decimal float modes, but it triggered
a failure with an upcoming patch.

Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu.
OK to install?

Thanks,
Richard


gcc/
	* fixed-value.c (check_real_for_fixed_mode, fixed_from_string)
	(fixed_to_decimal, fixed_convert_from_real)
	(real_convert_from_fixed): Fix mode arguments to real_2expN.

diff --git a/gcc/fixed-value.c b/gcc/fixed-value.c
index 39bdebe..a38045f 100644
--- a/gcc/fixed-value.c
+++ b/gcc/fixed-value.c
@@ -64,8 +64,8 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, machine_mode mode)
 {
   REAL_VALUE_TYPE max_value, min_value, epsilon_value;
 
-  real_2expN (&max_value, GET_MODE_IBIT (mode), mode);
-  real_2expN (&epsilon_value, -GET_MODE_FBIT (mode), mode);
+  real_2expN (&max_value, GET_MODE_IBIT (mode), VOIDmode);
+  real_2expN (&epsilon_value, -GET_MODE_FBIT (mode), VOIDmode);
 
   if (SIGNED_FIXED_POINT_MODE_P (mode))
     min_value = real_value_negate (&max_value);
@@ -127,7 +127,7 @@ fixed_from_string (FIXED_VALUE_TYPE *f, const char *str, machine_mode mode)
       || (temp == FIXED_MAX_EPS && ALL_ACCUM_MODE_P (f->mode)))
     warning (OPT_Woverflow,
 	     "large fixed-point constant implicitly truncated to fixed-point type");
-  real_2expN (&base_value, fbit, mode);
+  real_2expN (&base_value, fbit, VOIDmode);
   real_arithmetic (&fixed_value, MULT_EXPR, &real_value, &base_value);
   wide_int w = real_to_integer (&fixed_value, &fail,
 				GET_MODE_PRECISION (mode));
@@ -158,7 +158,7 @@ fixed_to_decimal (char *str, const FIXED_VALUE_TYPE *f_orig,
   REAL_VALUE_TYPE real_value, base_value, fixed_value;
 
   signop sgn = UNSIGNED_FIXED_POINT_MODE_P (f_orig->mode) ? UNSIGNED : SIGNED;
-  real_2expN (&base_value, GET_MODE_FBIT (f_orig->mode), f_orig->mode);
+  real_2expN (&base_value, GET_MODE_FBIT (f_orig->mode), VOIDmode);
   real_from_integer (&real_value, VOIDmode,
 		     wide_int::from (f_orig->data,
 				     GET_MODE_PRECISION (f_orig->mode), sgn),
@@ -1052,7 +1052,7 @@ fixed_convert_from_real (FIXED_VALUE_TYPE *f, machine_mode mode,
 
   real_value = *a;
   f->mode = mode;
-  real_2expN (&base_value, fbit, mode);
+  real_2expN (&base_value, fbit, VOIDmode);
   real_arithmetic (&fixed_value, MULT_EXPR, &real_value, &base_value);
 
   wide_int w = real_to_integer (&fixed_value, &fail,
@@ -1104,7 +1104,7 @@ real_convert_from_fixed (REAL_VALUE_TYPE *r, machine_mode mode,
   REAL_VALUE_TYPE base_value, fixed_value, real_value;
 
   signop sgn = UNSIGNED_FIXED_POINT_MODE_P (f->mode) ? UNSIGNED : SIGNED;
-  real_2expN (&base_value, GET_MODE_FBIT (f->mode), f->mode);
+  real_2expN (&base_value, GET_MODE_FBIT (f->mode), VOIDmode);
   real_from_integer (&fixed_value, VOIDmode,
 		     wide_int::from (f->data, GET_MODE_PRECISION (f->mode),
 				     sgn), sgn);

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

* Re: Fix real_2expN mode arguments in fixed-value.c
  2015-10-29 15:30 Fix real_2expN mode arguments in fixed-value.c Richard Sandiford
@ 2015-10-29 15:47 ` Bernd Schmidt
  2015-10-29 16:09   ` Richard Sandiford
  2015-10-29 16:23 ` Richard Biener
  1 sibling, 1 reply; 4+ messages in thread
From: Bernd Schmidt @ 2015-10-29 15:47 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 10/29/2015 04:28 PM, Richard Sandiford wrote:
> 	* fixed-value.c (check_real_for_fixed_mode, fixed_from_string)
> 	(fixed_to_decimal, fixed_convert_from_real)
> 	(real_convert_from_fixed): Fix mode arguments to real_2expN.

Passing VOIDmode rather than the real mode is a bit of a strange fix. 
Why can't the called function deal with the proper mode? (real_2expN 
also doesn't document the mode argument which should be fixed).


Bernd

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

* Re: Fix real_2expN mode arguments in fixed-value.c
  2015-10-29 15:47 ` Bernd Schmidt
@ 2015-10-29 16:09   ` Richard Sandiford
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Sandiford @ 2015-10-29 16:09 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: gcc-patches

Bernd Schmidt <bschmidt@redhat.com> writes:
> On 10/29/2015 04:28 PM, Richard Sandiford wrote:
>> 	* fixed-value.c (check_real_for_fixed_mode, fixed_from_string)
>> 	(fixed_to_decimal, fixed_convert_from_real)
>> 	(real_convert_from_fixed): Fix mode arguments to real_2expN.
>
> Passing VOIDmode rather than the real mode is a bit of a strange fix. 
> Why can't the called function deal with the proper mode? (real_2expN 
> also doesn't document the mode argument which should be fixed).

VOIDmode is the usual real.[hc] way of getting maximum precision,
which I think is the natural choice for these temporary real_values.
The mode only becomes significant when you want to round the result.

Thanks,
Richard

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

* Re: Fix real_2expN mode arguments in fixed-value.c
  2015-10-29 15:30 Fix real_2expN mode arguments in fixed-value.c Richard Sandiford
  2015-10-29 15:47 ` Bernd Schmidt
@ 2015-10-29 16:23 ` Richard Biener
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Biener @ 2015-10-29 16:23 UTC (permalink / raw)
  To: Richard Sandiford, gcc-patches

On October 29, 2015 4:28:05 PM GMT+01:00, Richard Sandiford <richard.sandiford@arm.com> wrote:
>fixed-value.c was passing a fixed-point mode to the floating-point
>real_2expN routine.  That didn't cause a problem in practice because
>all real_2expN did was check for decimal float modes, but it triggered
>a failure with an upcoming patch.
>
>Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu.
>OK to install?

OK.

Richard.

>Thanks,
>Richard
>
>
>gcc/
>	* fixed-value.c (check_real_for_fixed_mode, fixed_from_string)
>	(fixed_to_decimal, fixed_convert_from_real)
>	(real_convert_from_fixed): Fix mode arguments to real_2expN.
>
>diff --git a/gcc/fixed-value.c b/gcc/fixed-value.c
>index 39bdebe..a38045f 100644
>--- a/gcc/fixed-value.c
>+++ b/gcc/fixed-value.c
>@@ -64,8 +64,8 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE
>*real_value, machine_mode mode)
> {
>   REAL_VALUE_TYPE max_value, min_value, epsilon_value;
> 
>-  real_2expN (&max_value, GET_MODE_IBIT (mode), mode);
>-  real_2expN (&epsilon_value, -GET_MODE_FBIT (mode), mode);
>+  real_2expN (&max_value, GET_MODE_IBIT (mode), VOIDmode);
>+  real_2expN (&epsilon_value, -GET_MODE_FBIT (mode), VOIDmode);
> 
>   if (SIGNED_FIXED_POINT_MODE_P (mode))
>     min_value = real_value_negate (&max_value);
>@@ -127,7 +127,7 @@ fixed_from_string (FIXED_VALUE_TYPE *f, const char
>*str, machine_mode mode)
>       || (temp == FIXED_MAX_EPS && ALL_ACCUM_MODE_P (f->mode)))
>     warning (OPT_Woverflow,
>	     "large fixed-point constant implicitly truncated to fixed-point
>type");
>-  real_2expN (&base_value, fbit, mode);
>+  real_2expN (&base_value, fbit, VOIDmode);
>   real_arithmetic (&fixed_value, MULT_EXPR, &real_value, &base_value);
>   wide_int w = real_to_integer (&fixed_value, &fail,
> 				GET_MODE_PRECISION (mode));
>@@ -158,7 +158,7 @@ fixed_to_decimal (char *str, const FIXED_VALUE_TYPE
>*f_orig,
>   REAL_VALUE_TYPE real_value, base_value, fixed_value;
> 
>signop sgn = UNSIGNED_FIXED_POINT_MODE_P (f_orig->mode) ? UNSIGNED :
>SIGNED;
>-  real_2expN (&base_value, GET_MODE_FBIT (f_orig->mode),
>f_orig->mode);
>+  real_2expN (&base_value, GET_MODE_FBIT (f_orig->mode), VOIDmode);
>   real_from_integer (&real_value, VOIDmode,
> 		     wide_int::from (f_orig->data,
> 				     GET_MODE_PRECISION (f_orig->mode), sgn),
>@@ -1052,7 +1052,7 @@ fixed_convert_from_real (FIXED_VALUE_TYPE *f,
>machine_mode mode,
> 
>   real_value = *a;
>   f->mode = mode;
>-  real_2expN (&base_value, fbit, mode);
>+  real_2expN (&base_value, fbit, VOIDmode);
>   real_arithmetic (&fixed_value, MULT_EXPR, &real_value, &base_value);
> 
>   wide_int w = real_to_integer (&fixed_value, &fail,
>@@ -1104,7 +1104,7 @@ real_convert_from_fixed (REAL_VALUE_TYPE *r,
>machine_mode mode,
>   REAL_VALUE_TYPE base_value, fixed_value, real_value;
> 
>signop sgn = UNSIGNED_FIXED_POINT_MODE_P (f->mode) ? UNSIGNED : SIGNED;
>-  real_2expN (&base_value, GET_MODE_FBIT (f->mode), f->mode);
>+  real_2expN (&base_value, GET_MODE_FBIT (f->mode), VOIDmode);
>   real_from_integer (&fixed_value, VOIDmode,
> 		     wide_int::from (f->data, GET_MODE_PRECISION (f->mode),
> 				     sgn), sgn);


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

end of thread, other threads:[~2015-10-29 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 15:30 Fix real_2expN mode arguments in fixed-value.c Richard Sandiford
2015-10-29 15:47 ` Bernd Schmidt
2015-10-29 16:09   ` Richard Sandiford
2015-10-29 16:23 ` 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).