range-op-float: Further foperator_{,not_}equal::fold_range fix

Message ID ZCa8nVSkandaSH2N@tucnak
State Unresolved
Headers
Series range-op-float: Further foperator_{,not_}equal::fold_range fix |

Checks

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

Commit Message

Jakub Jelinek March 31, 2023, 10:57 a.m. UTC
  On Fri, Mar 31, 2023 at 12:45:10PM +0200, Jakub Jelinek via Gcc-patches wrote:
>    - there is a missing case (not handled in this patch) where both operands
>      are known to be zeros, but not singleton zeros

This patch adds those cases.

Ok for trunk if it passes bootstrap/regtest?

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

	* range-op-float.cc (foperator_equal::fold_range): If at least
	one of the op ranges is not singleton and neither is NaN and all
	4 bounds are zero, return [1, 1].
	(foperator_not_equal::fold_range): In the same case return [0, 0].



	Jakub
  

Comments

Aldy Hernandez March 31, 2023, 11:28 a.m. UTC | #1
On 3/31/23 12:57, Jakub Jelinek wrote:
> On Fri, Mar 31, 2023 at 12:45:10PM +0200, Jakub Jelinek via Gcc-patches wrote:
>>     - there is a missing case (not handled in this patch) where both operands
>>       are known to be zeros, but not singleton zeros
> 
> This patch adds those cases.
> 
> Ok for trunk if it passes bootstrap/regtest?

LGTM.

Thanks so much for taking care of all this.
Aldy

> 
> 2023-03-31  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* range-op-float.cc (foperator_equal::fold_range): If at least
> 	one of the op ranges is not singleton and neither is NaN and all
> 	4 bounds are zero, return [1, 1].
> 	(foperator_not_equal::fold_range): In the same case return [0, 0].
> 
> --- gcc/range-op-float.cc.jj	2023-03-31 11:23:04.817876083 +0200
> +++ gcc/range-op-float.cc	2023-03-31 12:51:34.757480162 +0200
> @@ -616,6 +616,13 @@ foperator_equal::fold_range (irange &r,
>         else
>   	r = range_false (type);
>       }
> +  else if (real_iszero (&op1.lower_bound ())
> +	   && real_iszero (&op1.upper_bound ())
> +	   && real_iszero (&op2.lower_bound ())
> +	   && real_iszero (&op2.upper_bound ())
> +	   && !maybe_isnan (op1, op2))
> +    // [-0.0, 0.0] == [-0.0, 0.0] or similar.
> +    r = range_true (type);
>     else
>       {
>         // If ranges do not intersect, we know the range is not equal,
> @@ -732,6 +739,13 @@ foperator_not_equal::fold_range (irange
>         else
>   	r = range_true (type);
>       }
> +  else if (real_iszero (&op1.lower_bound ())
> +	   && real_iszero (&op1.upper_bound ())
> +	   && real_iszero (&op2.lower_bound ())
> +	   && real_iszero (&op2.upper_bound ())
> +	   && !maybe_isnan (op1, op2))
> +    // [-0.0, 0.0] != [-0.0, 0.0] or similar.
> +    r = range_false (type);
>     else
>       {
>         // If ranges do not intersect, we know the range is not equal,
> 
> 
> 	Jakub
>
  

Patch

--- gcc/range-op-float.cc.jj	2023-03-31 11:23:04.817876083 +0200
+++ gcc/range-op-float.cc	2023-03-31 12:51:34.757480162 +0200
@@ -616,6 +616,13 @@  foperator_equal::fold_range (irange &r,
       else
 	r = range_false (type);
     }
+  else if (real_iszero (&op1.lower_bound ())
+	   && real_iszero (&op1.upper_bound ())
+	   && real_iszero (&op2.lower_bound ())
+	   && real_iszero (&op2.upper_bound ())
+	   && !maybe_isnan (op1, op2))
+    // [-0.0, 0.0] == [-0.0, 0.0] or similar.
+    r = range_true (type);
   else
     {
       // If ranges do not intersect, we know the range is not equal,
@@ -732,6 +739,13 @@  foperator_not_equal::fold_range (irange
       else
 	r = range_true (type);
     }
+  else if (real_iszero (&op1.lower_bound ())
+	   && real_iszero (&op1.upper_bound ())
+	   && real_iszero (&op2.lower_bound ())
+	   && real_iszero (&op2.upper_bound ())
+	   && !maybe_isnan (op1, op2))
+    // [-0.0, 0.0] != [-0.0, 0.0] or similar.
+    r = range_false (type);
   else
     {
       // If ranges do not intersect, we know the range is not equal,