range-op-float: Use get_nan_state in float_widen_lhs_range

Message ID ZCKdJtsc0vDzPq12@tucnak
State Unresolved
Headers
Series range-op-float: Use get_nan_state in float_widen_lhs_range |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek March 28, 2023, 7:54 a.m. UTC
  Hi!

On Wed, Mar 22, 2023 at 07:32:44AM +0100, Aldy Hernandez wrote:
> 	* value-range.cc (frange::set): Add nan_state argument.
> 	* value-range.h (class nan_state): New.
> 	(frange::get_nan_state): New.

The following patch makes use of those changes in float_widen_lhs_range.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

	* range-op-float.cc (float_widen_lhs_range): Use pass get_nan_state
	as 4th argument to set to avoid clear_nan and union_ calls.



	Jakub
  

Comments

Aldy Hernandez March 28, 2023, 8:50 a.m. UTC | #1
On 3/28/23 09:54, Jakub Jelinek wrote:
> Hi!
> 
> On Wed, Mar 22, 2023 at 07:32:44AM +0100, Aldy Hernandez wrote:
>> 	* value-range.cc (frange::set): Add nan_state argument.
>> 	* value-range.h (class nan_state): New.
>> 	(frange::get_nan_state): New.
> 
> The following patch makes use of those changes in float_widen_lhs_range.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

LGTM.
Aldy
> 
> 2023-03-28  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* range-op-float.cc (float_widen_lhs_range): Use pass get_nan_state
> 	as 4th argument to set to avoid clear_nan and union_ calls.
> 
> --- gcc/range-op-float.cc.jj	2023-03-23 15:25:47.119740274 +0100
> +++ gcc/range-op-float.cc	2023-03-27 13:28:18.847264635 +0200
> @@ -2262,12 +2262,7 @@ float_widen_lhs_range (tree type, const
>        or real_max_representable (type) as upper bound.  */
>     bool save_flag_finite_math_only = flag_finite_math_only;
>     flag_finite_math_only = false;
> -  ret.set (type, lb, ub);
> -  if (lhs.kind () != VR_VARYING)
> -    {
> -      ret.clear_nan ();
> -      ret.union_ (lhs);
> -    }
> +  ret.set (type, lb, ub, lhs.get_nan_state ());
>     flag_finite_math_only = save_flag_finite_math_only;
>     return ret;
>   }
> 
> 
> 	Jakub
>
  
Aldy Hernandez March 29, 2023, 9:39 a.m. UTC | #2
On 3/28/23 10:50, Aldy Hernandez wrote:
> 
> 
> On 3/28/23 09:54, Jakub Jelinek wrote:
>> Hi!
>>
>> On Wed, Mar 22, 2023 at 07:32:44AM +0100, Aldy Hernandez wrote:
>>>     * value-range.cc (frange::set): Add nan_state argument.
>>>     * value-range.h (class nan_state): New.
>>>     (frange::get_nan_state): New.
>>
>> The following patch makes use of those changes in float_widen_lhs_range.
>>
>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> LGTM.
> Aldy
>>
>> 2023-03-28  Jakub Jelinek  <jakub@redhat.com>
>>
>>     * range-op-float.cc (float_widen_lhs_range): Use pass get_nan_state
>>     as 4th argument to set to avoid clear_nan and union_ calls.
>>
>> --- gcc/range-op-float.cc.jj    2023-03-23 15:25:47.119740274 +0100
>> +++ gcc/range-op-float.cc    2023-03-27 13:28:18.847264635 +0200
>> @@ -2262,12 +2262,7 @@ float_widen_lhs_range (tree type, const
>>        or real_max_representable (type) as upper bound.  */
>>     bool save_flag_finite_math_only = flag_finite_math_only;
>>     flag_finite_math_only = false;
>> -  ret.set (type, lb, ub);
>> -  if (lhs.kind () != VR_VARYING)
>> -    {
>> -      ret.clear_nan ();
>> -      ret.union_ (lhs);
>> -    }
>> +  ret.set (type, lb, ub, lhs.get_nan_state ());
>>     flag_finite_math_only = save_flag_finite_math_only;
>>     return ret;

I just noticed we're still doing the flag_finite_math_only hack.  We 
should add some sort of flag to the setter to avoid reducing the range. 
I suppose this can wait to the next release.

Aldy
  

Patch

--- gcc/range-op-float.cc.jj	2023-03-23 15:25:47.119740274 +0100
+++ gcc/range-op-float.cc	2023-03-27 13:28:18.847264635 +0200
@@ -2262,12 +2262,7 @@  float_widen_lhs_range (tree type, const
      or real_max_representable (type) as upper bound.  */
   bool save_flag_finite_math_only = flag_finite_math_only;
   flag_finite_math_only = false;
-  ret.set (type, lb, ub);
-  if (lhs.kind () != VR_VARYING)
-    {
-      ret.clear_nan ();
-      ret.union_ (lhs);
-    }
+  ret.set (type, lb, ub, lhs.get_nan_state ());
   flag_finite_math_only = save_flag_finite_math_only;
   return ret;
 }