public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH-2v4] Value Range: Add range op for builtin isfinite
@ 2024-05-30  2:46 HAO CHEN GUI
  2024-06-20  6:57 ` HAO CHEN GUI
  0 siblings, 1 reply; 8+ messages in thread
From: HAO CHEN GUI @ 2024-05-30  2:46 UTC (permalink / raw)
  To: gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford

Hi,
  This patch adds the range op for builtin isfinite.

  Compared to previous version, the main change is to set the range to
1 if it's finite number otherwise to 0.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652220.html

  Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
regressions. Is it OK for the trunk?

Thanks
Gui Haochen

ChangeLog
Value Range: Add range op for builtin isfinite

The former patch adds optab for builtin isfinite. Thus builtin isfinite
might not be folded at front end.  So the range op for isfinite is needed
for value range analysis.  This patch adds range op for builtin isfinite.

gcc/
	* gimple-range-op.cc (class cfn_isfinite): New.
	(op_cfn_finite): New variables.
	(gimple_range_op_handler::maybe_builtin_call): Handle
	CFN_BUILT_IN_ISFINITE.

gcc/testsuite/
	* gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c: New test.

patch.diff
diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index 4e60a42eaac..5ec5c828fa4 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -1233,6 +1233,62 @@ public:
   }
 } op_cfn_isinf;

+//Implement range operator for CFN_BUILT_IN_ISFINITE
+class cfn_isfinite : public range_operator
+{
+public:
+  using range_operator::fold_range;
+  using range_operator::op1_range;
+  virtual bool fold_range (irange &r, tree type, const frange &op1,
+			   const irange &, relation_trio) const override
+  {
+    if (op1.undefined_p ())
+      return false;
+
+    if (op1.known_isfinite ())
+      {
+	wide_int one = wi::one (TYPE_PRECISION (type));
+	r.set (type, one, one);
+	return true;
+      }
+
+    if (op1.known_isnan ()
+	|| op1.known_isinf ())
+      {
+	r.set_zero (type);
+	return true;
+      }
+
+    r.set_varying (type);
+    return true;
+  }
+  virtual bool op1_range (frange &r, tree type, const irange &lhs,
+			  const frange &, relation_trio) const override
+  {
+    if (lhs.undefined_p ())
+      return false;
+
+    if (lhs.zero_p ())
+      {
+	// The range is [-INF,-INF][+INF,+INF] NAN, but it can't be represented.
+	// Set range to varying
+	r.set_varying (type);
+	return true;
+      }
+
+    if (!range_includes_zero_p (lhs))
+      {
+	nan_state nan (false);
+	r.set (type, real_min_representable (type),
+	       real_max_representable (type), nan);
+	return true;
+      }
+
+    r.set_varying (type);
+    return true;
+  }
+} op_cfn_isfinite;
+
 // Implement range operator for CFN_BUILT_IN_
 class cfn_parity : public range_operator
 {
@@ -1330,6 +1386,11 @@ gimple_range_op_handler::maybe_builtin_call ()
       m_operator = &op_cfn_isinf;
       break;

+    case CFN_BUILT_IN_ISFINITE:
+      m_op1 = gimple_call_arg (call, 0);
+      m_operator = &op_cfn_isfinite;
+      break;
+
     CASE_CFN_COPYSIGN_ALL:
       m_op1 = gimple_call_arg (call, 0);
       m_op2 = gimple_call_arg (call, 1);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
new file mode 100644
index 00000000000..f5dce0a0486
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+#include <math.h>
+void link_error();
+
+void test1 (double x)
+{
+  if (x < __DBL_MAX__ && x > -__DBL_MAX__ && !__builtin_isfinite (x))
+    link_error ();
+}
+
+void test2 (float x)
+{
+  if (x < __FLT_MAX__ && x > -__FLT_MAX__ && !__builtin_isfinite (x))
+    link_error ();
+}
+
+void test3 (double x)
+{
+  if (__builtin_isfinite (x) && __builtin_isinf (x))
+    link_error ();
+}
+
+void test4 (float x)
+{
+  if (__builtin_isfinite (x) && __builtin_isinf (x))
+    link_error ();
+}
+
+/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */

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

* Re: [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-05-30  2:46 [PATCH-2v4] Value Range: Add range op for builtin isfinite HAO CHEN GUI
@ 2024-06-20  6:57 ` HAO CHEN GUI
  2024-06-24  1:41   ` Ping^2 " HAO CHEN GUI
  0 siblings, 1 reply; 8+ messages in thread
From: HAO CHEN GUI @ 2024-06-20  6:57 UTC (permalink / raw)
  To: gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford

Hi,
  Gently ping it.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html

Thanks
Gui Haochen

在 2024/5/30 10:46, HAO CHEN GUI 写道:
> Hi,
>   This patch adds the range op for builtin isfinite.
> 
>   Compared to previous version, the main change is to set the range to
> 1 if it's finite number otherwise to 0.
> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652220.html
> 
>   Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
> regressions. Is it OK for the trunk?
> 
> Thanks
> Gui Haochen
> 
> ChangeLog
> Value Range: Add range op for builtin isfinite
> 
> The former patch adds optab for builtin isfinite. Thus builtin isfinite
> might not be folded at front end.  So the range op for isfinite is needed
> for value range analysis.  This patch adds range op for builtin isfinite.
> 
> gcc/
> 	* gimple-range-op.cc (class cfn_isfinite): New.
> 	(op_cfn_finite): New variables.
> 	(gimple_range_op_handler::maybe_builtin_call): Handle
> 	CFN_BUILT_IN_ISFINITE.
> 
> gcc/testsuite/
> 	* gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c: New test.
> 
> patch.diff
> diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
> index 4e60a42eaac..5ec5c828fa4 100644
> --- a/gcc/gimple-range-op.cc
> +++ b/gcc/gimple-range-op.cc
> @@ -1233,6 +1233,62 @@ public:
>    }
>  } op_cfn_isinf;
> 
> +//Implement range operator for CFN_BUILT_IN_ISFINITE
> +class cfn_isfinite : public range_operator
> +{
> +public:
> +  using range_operator::fold_range;
> +  using range_operator::op1_range;
> +  virtual bool fold_range (irange &r, tree type, const frange &op1,
> +			   const irange &, relation_trio) const override
> +  {
> +    if (op1.undefined_p ())
> +      return false;
> +
> +    if (op1.known_isfinite ())
> +      {
> +	wide_int one = wi::one (TYPE_PRECISION (type));
> +	r.set (type, one, one);
> +	return true;
> +      }
> +
> +    if (op1.known_isnan ()
> +	|| op1.known_isinf ())
> +      {
> +	r.set_zero (type);
> +	return true;
> +      }
> +
> +    r.set_varying (type);
> +    return true;
> +  }
> +  virtual bool op1_range (frange &r, tree type, const irange &lhs,
> +			  const frange &, relation_trio) const override
> +  {
> +    if (lhs.undefined_p ())
> +      return false;
> +
> +    if (lhs.zero_p ())
> +      {
> +	// The range is [-INF,-INF][+INF,+INF] NAN, but it can't be represented.
> +	// Set range to varying
> +	r.set_varying (type);
> +	return true;
> +      }
> +
> +    if (!range_includes_zero_p (lhs))
> +      {
> +	nan_state nan (false);
> +	r.set (type, real_min_representable (type),
> +	       real_max_representable (type), nan);
> +	return true;
> +      }
> +
> +    r.set_varying (type);
> +    return true;
> +  }
> +} op_cfn_isfinite;
> +
>  // Implement range operator for CFN_BUILT_IN_
>  class cfn_parity : public range_operator
>  {
> @@ -1330,6 +1386,11 @@ gimple_range_op_handler::maybe_builtin_call ()
>        m_operator = &op_cfn_isinf;
>        break;
> 
> +    case CFN_BUILT_IN_ISFINITE:
> +      m_op1 = gimple_call_arg (call, 0);
> +      m_operator = &op_cfn_isfinite;
> +      break;
> +
>      CASE_CFN_COPYSIGN_ALL:
>        m_op1 = gimple_call_arg (call, 0);
>        m_op2 = gimple_call_arg (call, 1);
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
> new file mode 100644
> index 00000000000..f5dce0a0486
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
> @@ -0,0 +1,31 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-evrp" } */
> +
> +#include <math.h>
> +void link_error();
> +
> +void test1 (double x)
> +{
> +  if (x < __DBL_MAX__ && x > -__DBL_MAX__ && !__builtin_isfinite (x))
> +    link_error ();
> +}
> +
> +void test2 (float x)
> +{
> +  if (x < __FLT_MAX__ && x > -__FLT_MAX__ && !__builtin_isfinite (x))
> +    link_error ();
> +}
> +
> +void test3 (double x)
> +{
> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
> +    link_error ();
> +}
> +
> +void test4 (float x)
> +{
> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
> +    link_error ();
> +}
> +
> +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */

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

* Ping^2 [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-06-20  6:57 ` HAO CHEN GUI
@ 2024-06-24  1:41   ` HAO CHEN GUI
  2024-07-01  1:11     ` Ping^3 " HAO CHEN GUI
  0 siblings, 1 reply; 8+ messages in thread
From: HAO CHEN GUI @ 2024-06-24  1:41 UTC (permalink / raw)
  To: gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford

Hi,
  Gently ping it.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html

Thanks
Gui Haochen

在 2024/6/20 14:57, HAO CHEN GUI 写道:
> Hi,
>   Gently ping it.
> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
> 
> Thanks
> Gui Haochen
> 
> 在 2024/5/30 10:46, HAO CHEN GUI 写道:
>> Hi,
>>   This patch adds the range op for builtin isfinite.
>>
>>   Compared to previous version, the main change is to set the range to
>> 1 if it's finite number otherwise to 0.
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652220.html
>>
>>   Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
>> regressions. Is it OK for the trunk?
>>
>> Thanks
>> Gui Haochen
>>
>> ChangeLog
>> Value Range: Add range op for builtin isfinite
>>
>> The former patch adds optab for builtin isfinite. Thus builtin isfinite
>> might not be folded at front end.  So the range op for isfinite is needed
>> for value range analysis.  This patch adds range op for builtin isfinite.
>>
>> gcc/
>> 	* gimple-range-op.cc (class cfn_isfinite): New.
>> 	(op_cfn_finite): New variables.
>> 	(gimple_range_op_handler::maybe_builtin_call): Handle
>> 	CFN_BUILT_IN_ISFINITE.
>>
>> gcc/testsuite/
>> 	* gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c: New test.
>>
>> patch.diff
>> diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
>> index 4e60a42eaac..5ec5c828fa4 100644
>> --- a/gcc/gimple-range-op.cc
>> +++ b/gcc/gimple-range-op.cc
>> @@ -1233,6 +1233,62 @@ public:
>>    }
>>  } op_cfn_isinf;
>>
>> +//Implement range operator for CFN_BUILT_IN_ISFINITE
>> +class cfn_isfinite : public range_operator
>> +{
>> +public:
>> +  using range_operator::fold_range;
>> +  using range_operator::op1_range;
>> +  virtual bool fold_range (irange &r, tree type, const frange &op1,
>> +			   const irange &, relation_trio) const override
>> +  {
>> +    if (op1.undefined_p ())
>> +      return false;
>> +
>> +    if (op1.known_isfinite ())
>> +      {
>> +	wide_int one = wi::one (TYPE_PRECISION (type));
>> +	r.set (type, one, one);
>> +	return true;
>> +      }
>> +
>> +    if (op1.known_isnan ()
>> +	|| op1.known_isinf ())
>> +      {
>> +	r.set_zero (type);
>> +	return true;
>> +      }
>> +
>> +    r.set_varying (type);
>> +    return true;
>> +  }
>> +  virtual bool op1_range (frange &r, tree type, const irange &lhs,
>> +			  const frange &, relation_trio) const override
>> +  {
>> +    if (lhs.undefined_p ())
>> +      return false;
>> +
>> +    if (lhs.zero_p ())
>> +      {
>> +	// The range is [-INF,-INF][+INF,+INF] NAN, but it can't be represented.
>> +	// Set range to varying
>> +	r.set_varying (type);
>> +	return true;
>> +      }
>> +
>> +    if (!range_includes_zero_p (lhs))
>> +      {
>> +	nan_state nan (false);
>> +	r.set (type, real_min_representable (type),
>> +	       real_max_representable (type), nan);
>> +	return true;
>> +      }
>> +
>> +    r.set_varying (type);
>> +    return true;
>> +  }
>> +} op_cfn_isfinite;
>> +
>>  // Implement range operator for CFN_BUILT_IN_
>>  class cfn_parity : public range_operator
>>  {
>> @@ -1330,6 +1386,11 @@ gimple_range_op_handler::maybe_builtin_call ()
>>        m_operator = &op_cfn_isinf;
>>        break;
>>
>> +    case CFN_BUILT_IN_ISFINITE:
>> +      m_op1 = gimple_call_arg (call, 0);
>> +      m_operator = &op_cfn_isfinite;
>> +      break;
>> +
>>      CASE_CFN_COPYSIGN_ALL:
>>        m_op1 = gimple_call_arg (call, 0);
>>        m_op2 = gimple_call_arg (call, 1);
>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
>> new file mode 100644
>> index 00000000000..f5dce0a0486
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
>> @@ -0,0 +1,31 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -fdump-tree-evrp" } */
>> +
>> +#include <math.h>
>> +void link_error();
>> +
>> +void test1 (double x)
>> +{
>> +  if (x < __DBL_MAX__ && x > -__DBL_MAX__ && !__builtin_isfinite (x))
>> +    link_error ();
>> +}
>> +
>> +void test2 (float x)
>> +{
>> +  if (x < __FLT_MAX__ && x > -__FLT_MAX__ && !__builtin_isfinite (x))
>> +    link_error ();
>> +}
>> +
>> +void test3 (double x)
>> +{
>> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
>> +    link_error ();
>> +}
>> +
>> +void test4 (float x)
>> +{
>> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
>> +    link_error ();
>> +}
>> +
>> +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */

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

* Ping^3 [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-06-24  1:41   ` Ping^2 " HAO CHEN GUI
@ 2024-07-01  1:11     ` HAO CHEN GUI
  2024-07-22  2:10       ` Ping^4 " HAO CHEN GUI
  0 siblings, 1 reply; 8+ messages in thread
From: HAO CHEN GUI @ 2024-07-01  1:11 UTC (permalink / raw)
  To: gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford

Hi,
  Gently ping it.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html

Thanks
Gui Haochen

在 2024/6/24 9:41, HAO CHEN GUI 写道:
> Hi,
>   Gently ping it.
> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
> 
> Thanks
> Gui Haochen
> 
> 在 2024/6/20 14:57, HAO CHEN GUI 写道:
>> Hi,
>>   Gently ping it.
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
>>
>> Thanks
>> Gui Haochen
>>
>> 在 2024/5/30 10:46, HAO CHEN GUI 写道:
>>> Hi,
>>>   This patch adds the range op for builtin isfinite.
>>>
>>>   Compared to previous version, the main change is to set the range to
>>> 1 if it's finite number otherwise to 0.
>>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652220.html
>>>
>>>   Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
>>> regressions. Is it OK for the trunk?
>>>
>>> Thanks
>>> Gui Haochen
>>>
>>> ChangeLog
>>> Value Range: Add range op for builtin isfinite
>>>
>>> The former patch adds optab for builtin isfinite. Thus builtin isfinite
>>> might not be folded at front end.  So the range op for isfinite is needed
>>> for value range analysis.  This patch adds range op for builtin isfinite.
>>>
>>> gcc/
>>> 	* gimple-range-op.cc (class cfn_isfinite): New.
>>> 	(op_cfn_finite): New variables.
>>> 	(gimple_range_op_handler::maybe_builtin_call): Handle
>>> 	CFN_BUILT_IN_ISFINITE.
>>>
>>> gcc/testsuite/
>>> 	* gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c: New test.
>>>
>>> patch.diff
>>> diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
>>> index 4e60a42eaac..5ec5c828fa4 100644
>>> --- a/gcc/gimple-range-op.cc
>>> +++ b/gcc/gimple-range-op.cc
>>> @@ -1233,6 +1233,62 @@ public:
>>>    }
>>>  } op_cfn_isinf;
>>>
>>> +//Implement range operator for CFN_BUILT_IN_ISFINITE
>>> +class cfn_isfinite : public range_operator
>>> +{
>>> +public:
>>> +  using range_operator::fold_range;
>>> +  using range_operator::op1_range;
>>> +  virtual bool fold_range (irange &r, tree type, const frange &op1,
>>> +			   const irange &, relation_trio) const override
>>> +  {
>>> +    if (op1.undefined_p ())
>>> +      return false;
>>> +
>>> +    if (op1.known_isfinite ())
>>> +      {
>>> +	wide_int one = wi::one (TYPE_PRECISION (type));
>>> +	r.set (type, one, one);
>>> +	return true;
>>> +      }
>>> +
>>> +    if (op1.known_isnan ()
>>> +	|| op1.known_isinf ())
>>> +      {
>>> +	r.set_zero (type);
>>> +	return true;
>>> +      }
>>> +
>>> +    r.set_varying (type);
>>> +    return true;
>>> +  }
>>> +  virtual bool op1_range (frange &r, tree type, const irange &lhs,
>>> +			  const frange &, relation_trio) const override
>>> +  {
>>> +    if (lhs.undefined_p ())
>>> +      return false;
>>> +
>>> +    if (lhs.zero_p ())
>>> +      {
>>> +	// The range is [-INF,-INF][+INF,+INF] NAN, but it can't be represented.
>>> +	// Set range to varying
>>> +	r.set_varying (type);
>>> +	return true;
>>> +      }
>>> +
>>> +    if (!range_includes_zero_p (lhs))
>>> +      {
>>> +	nan_state nan (false);
>>> +	r.set (type, real_min_representable (type),
>>> +	       real_max_representable (type), nan);
>>> +	return true;
>>> +      }
>>> +
>>> +    r.set_varying (type);
>>> +    return true;
>>> +  }
>>> +} op_cfn_isfinite;
>>> +
>>>  // Implement range operator for CFN_BUILT_IN_
>>>  class cfn_parity : public range_operator
>>>  {
>>> @@ -1330,6 +1386,11 @@ gimple_range_op_handler::maybe_builtin_call ()
>>>        m_operator = &op_cfn_isinf;
>>>        break;
>>>
>>> +    case CFN_BUILT_IN_ISFINITE:
>>> +      m_op1 = gimple_call_arg (call, 0);
>>> +      m_operator = &op_cfn_isfinite;
>>> +      break;
>>> +
>>>      CASE_CFN_COPYSIGN_ALL:
>>>        m_op1 = gimple_call_arg (call, 0);
>>>        m_op2 = gimple_call_arg (call, 1);
>>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
>>> new file mode 100644
>>> index 00000000000..f5dce0a0486
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
>>> @@ -0,0 +1,31 @@
>>> +/* { dg-do compile } */
>>> +/* { dg-options "-O2 -fdump-tree-evrp" } */
>>> +
>>> +#include <math.h>
>>> +void link_error();
>>> +
>>> +void test1 (double x)
>>> +{
>>> +  if (x < __DBL_MAX__ && x > -__DBL_MAX__ && !__builtin_isfinite (x))
>>> +    link_error ();
>>> +}
>>> +
>>> +void test2 (float x)
>>> +{
>>> +  if (x < __FLT_MAX__ && x > -__FLT_MAX__ && !__builtin_isfinite (x))
>>> +    link_error ();
>>> +}
>>> +
>>> +void test3 (double x)
>>> +{
>>> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
>>> +    link_error ();
>>> +}
>>> +
>>> +void test4 (float x)
>>> +{
>>> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
>>> +    link_error ();
>>> +}
>>> +
>>> +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */

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

* Ping^4 [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-07-01  1:11     ` Ping^3 " HAO CHEN GUI
@ 2024-07-22  2:10       ` HAO CHEN GUI
  2024-08-05 14:59         ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: HAO CHEN GUI @ 2024-07-22  2:10 UTC (permalink / raw)
  To: gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford, Jeff Law

Hi,
  Gently ping it.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html

Thanks
Gui Haochen

在 2024/7/1 9:11, HAO CHEN GUI 写道:
> Hi,
>   Gently ping it.
> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
> 
> Thanks
> Gui Haochen
> 
> 在 2024/6/24 9:41, HAO CHEN GUI 写道:
>> Hi,
>>   Gently ping it.
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
>>
>> Thanks
>> Gui Haochen
>>
>> 在 2024/6/20 14:57, HAO CHEN GUI 写道:
>>> Hi,
>>>   Gently ping it.
>>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
>>>
>>> Thanks
>>> Gui Haochen
>>>
>>> 在 2024/5/30 10:46, HAO CHEN GUI 写道:
>>>> Hi,
>>>>   This patch adds the range op for builtin isfinite.
>>>>
>>>>   Compared to previous version, the main change is to set the range to
>>>> 1 if it's finite number otherwise to 0.
>>>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652220.html
>>>>
>>>>   Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
>>>> regressions. Is it OK for the trunk?
>>>>
>>>> Thanks
>>>> Gui Haochen
>>>>
>>>> ChangeLog
>>>> Value Range: Add range op for builtin isfinite
>>>>
>>>> The former patch adds optab for builtin isfinite. Thus builtin isfinite
>>>> might not be folded at front end.  So the range op for isfinite is needed
>>>> for value range analysis.  This patch adds range op for builtin isfinite.
>>>>
>>>> gcc/
>>>> 	* gimple-range-op.cc (class cfn_isfinite): New.
>>>> 	(op_cfn_finite): New variables.
>>>> 	(gimple_range_op_handler::maybe_builtin_call): Handle
>>>> 	CFN_BUILT_IN_ISFINITE.
>>>>
>>>> gcc/testsuite/
>>>> 	* gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c: New test.
>>>>
>>>> patch.diff
>>>> diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
>>>> index 4e60a42eaac..5ec5c828fa4 100644
>>>> --- a/gcc/gimple-range-op.cc
>>>> +++ b/gcc/gimple-range-op.cc
>>>> @@ -1233,6 +1233,62 @@ public:
>>>>    }
>>>>  } op_cfn_isinf;
>>>>
>>>> +//Implement range operator for CFN_BUILT_IN_ISFINITE
>>>> +class cfn_isfinite : public range_operator
>>>> +{
>>>> +public:
>>>> +  using range_operator::fold_range;
>>>> +  using range_operator::op1_range;
>>>> +  virtual bool fold_range (irange &r, tree type, const frange &op1,
>>>> +			   const irange &, relation_trio) const override
>>>> +  {
>>>> +    if (op1.undefined_p ())
>>>> +      return false;
>>>> +
>>>> +    if (op1.known_isfinite ())
>>>> +      {
>>>> +	wide_int one = wi::one (TYPE_PRECISION (type));
>>>> +	r.set (type, one, one);
>>>> +	return true;
>>>> +      }
>>>> +
>>>> +    if (op1.known_isnan ()
>>>> +	|| op1.known_isinf ())
>>>> +      {
>>>> +	r.set_zero (type);
>>>> +	return true;
>>>> +      }
>>>> +
>>>> +    r.set_varying (type);
>>>> +    return true;
>>>> +  }
>>>> +  virtual bool op1_range (frange &r, tree type, const irange &lhs,
>>>> +			  const frange &, relation_trio) const override
>>>> +  {
>>>> +    if (lhs.undefined_p ())
>>>> +      return false;
>>>> +
>>>> +    if (lhs.zero_p ())
>>>> +      {
>>>> +	// The range is [-INF,-INF][+INF,+INF] NAN, but it can't be represented.
>>>> +	// Set range to varying
>>>> +	r.set_varying (type);
>>>> +	return true;
>>>> +      }
>>>> +
>>>> +    if (!range_includes_zero_p (lhs))
>>>> +      {
>>>> +	nan_state nan (false);
>>>> +	r.set (type, real_min_representable (type),
>>>> +	       real_max_representable (type), nan);
>>>> +	return true;
>>>> +      }
>>>> +
>>>> +    r.set_varying (type);
>>>> +    return true;
>>>> +  }
>>>> +} op_cfn_isfinite;
>>>> +
>>>>  // Implement range operator for CFN_BUILT_IN_
>>>>  class cfn_parity : public range_operator
>>>>  {
>>>> @@ -1330,6 +1386,11 @@ gimple_range_op_handler::maybe_builtin_call ()
>>>>        m_operator = &op_cfn_isinf;
>>>>        break;
>>>>
>>>> +    case CFN_BUILT_IN_ISFINITE:
>>>> +      m_op1 = gimple_call_arg (call, 0);
>>>> +      m_operator = &op_cfn_isfinite;
>>>> +      break;
>>>> +
>>>>      CASE_CFN_COPYSIGN_ALL:
>>>>        m_op1 = gimple_call_arg (call, 0);
>>>>        m_op2 = gimple_call_arg (call, 1);
>>>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
>>>> new file mode 100644
>>>> index 00000000000..f5dce0a0486
>>>> --- /dev/null
>>>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-isfinite.c
>>>> @@ -0,0 +1,31 @@
>>>> +/* { dg-do compile } */
>>>> +/* { dg-options "-O2 -fdump-tree-evrp" } */
>>>> +
>>>> +#include <math.h>
>>>> +void link_error();
>>>> +
>>>> +void test1 (double x)
>>>> +{
>>>> +  if (x < __DBL_MAX__ && x > -__DBL_MAX__ && !__builtin_isfinite (x))
>>>> +    link_error ();
>>>> +}
>>>> +
>>>> +void test2 (float x)
>>>> +{
>>>> +  if (x < __FLT_MAX__ && x > -__FLT_MAX__ && !__builtin_isfinite (x))
>>>> +    link_error ();
>>>> +}
>>>> +
>>>> +void test3 (double x)
>>>> +{
>>>> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
>>>> +    link_error ();
>>>> +}
>>>> +
>>>> +void test4 (float x)
>>>> +{
>>>> +  if (__builtin_isfinite (x) && __builtin_isinf (x))
>>>> +    link_error ();
>>>> +}
>>>> +
>>>> +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */

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

* Re: Ping^4 [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-07-22  2:10       ` Ping^4 " HAO CHEN GUI
@ 2024-08-05 14:59         ` Jeff Law
  2024-08-13 17:24           ` Vineet Gupta
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2024-08-05 14:59 UTC (permalink / raw)
  To: HAO CHEN GUI, gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford



On 7/21/24 8:10 PM, HAO CHEN GUI wrote:
> Hi,
>    Gently ping it.
> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
OK.  Sorry for the delays.

jeff


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

* Re: Ping^4 [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-08-05 14:59         ` Jeff Law
@ 2024-08-13 17:24           ` Vineet Gupta
  2024-08-14  7:25             ` HAO CHEN GUI
  0 siblings, 1 reply; 8+ messages in thread
From: Vineet Gupta @ 2024-08-13 17:24 UTC (permalink / raw)
  To: Jeff Law, HAO CHEN GUI, gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford

Hi Hao Gui,

Can you commit this soon - some of the arch patches might be waiting on this.

Thx,
-Vineet

On 8/5/24 07:59, Jeff Law wrote:
> On 7/21/24 8:10 PM, HAO CHEN GUI wrote:
>> Hi,
>>    Gently ping it.
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
> OK.  Sorry for the delays.

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

* Re: Ping^4 [PATCH-2v4] Value Range: Add range op for builtin isfinite
  2024-08-13 17:24           ` Vineet Gupta
@ 2024-08-14  7:25             ` HAO CHEN GUI
  0 siblings, 0 replies; 8+ messages in thread
From: HAO CHEN GUI @ 2024-08-14  7:25 UTC (permalink / raw)
  To: Vineet Gupta, Jeff Law, gcc-patches
  Cc: Segher Boessenkool, David, Kewen.Lin, Peter Bergner,
	Mikael Morin, MacLeod, Andrew, Aldy Hernandez, Jakub Jelinek,
	Richard Sandiford

Hi Vinnet,

  This patch (test cases) relies on former patch (range op for isinf) which
hasn't been approval yet. I will commit them as soon as the former patch get
approval.

Thanks
Gui Haochen

在 2024/8/14 1:24, Vineet Gupta 写道:
> Hi Hao Gui,
> 
> Can you commit this soon - some of the arch patches might be waiting on this.
> 
> Thx,
> -Vineet
> 
> On 8/5/24 07:59, Jeff Law wrote:
>> On 7/21/24 8:10 PM, HAO CHEN GUI wrote:
>>> Hi,
>>>    Gently ping it.
>>> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653094.html
>> OK.  Sorry for the delays.

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

end of thread, other threads:[~2024-08-14  7:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-30  2:46 [PATCH-2v4] Value Range: Add range op for builtin isfinite HAO CHEN GUI
2024-06-20  6:57 ` HAO CHEN GUI
2024-06-24  1:41   ` Ping^2 " HAO CHEN GUI
2024-07-01  1:11     ` Ping^3 " HAO CHEN GUI
2024-07-22  2:10       ` Ping^4 " HAO CHEN GUI
2024-08-05 14:59         ` Jeff Law
2024-08-13 17:24           ` Vineet Gupta
2024-08-14  7:25             ` HAO CHEN GUI

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).