* [tree-optimization/63387] Recognize isunordered
@ 2015-04-13 12:24 Marc Glisse
2015-04-13 12:36 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Marc Glisse @ 2015-04-13 12:24 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: TEXT/PLAIN, Size: 430 bytes --]
Hello,
just a simple pattern for match.pd. I am ignoring the issue of whether
isnan is the same as isunordered, I am only combining isunordered
together.
2015-04-13 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/63387
gcc/
* match.pd ((x unord x) | (y unord y) -> (x unord y),
(x unord x) | (x unord y) -> (x unord y)): New simplifications.
gcc/testsuite/
* gcc.dg/pr63387.c: New testcase.
--
Marc Glisse
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2146 bytes --]
Index: match.pd
===================================================================
--- match.pd (revision 222041)
+++ match.pd (working copy)
@@ -925,20 +925,27 @@ along with GCC; see the file COPYING3.
(ncmp @0 @1)))))
(simplify
(bit_xor (cmp @0 @1) integer_truep)
(with { enum tree_code ic = invert_tree_comparison
(cmp, HONOR_NANS (@0)); }
(if (ic == icmp)
(icmp @0 @1))
(if (ic == ncmp)
(ncmp @0 @1)))))
+/* Unordered tests if either argument is a NaN. */
+(simplify
+ (bit_ior (unordered @0 @0) (unordered @1 @1))
+ (unordered @0 @1))
+(simplify
+ (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
+ @2)
/* Simplification of math builtins. */
(define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL)
(define_operator_list EXP BUILT_IN_EXPF BUILT_IN_EXP BUILT_IN_EXPL)
(define_operator_list LOG2 BUILT_IN_LOG2F BUILT_IN_LOG2 BUILT_IN_LOG2L)
(define_operator_list EXP2 BUILT_IN_EXP2F BUILT_IN_EXP2 BUILT_IN_EXP2L)
(define_operator_list LOG10 BUILT_IN_LOG10F BUILT_IN_LOG10 BUILT_IN_LOG10L)
(define_operator_list EXP10 BUILT_IN_EXP10F BUILT_IN_EXP10 BUILT_IN_EXP10L)
(define_operator_list POW BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL)
Index: testsuite/gcc.dg/pr63387.c
===================================================================
--- testsuite/gcc.dg/pr63387.c (revision 0)
+++ testsuite/gcc.dg/pr63387.c (working copy)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+int f(double aaa, double bbb){
+ int xa = __builtin_isunordered(aaa, aaa);
+ int xb = __builtin_isunordered(bbb, bbb);
+ return xa | xb;
+}
+
+int g(double aaa, double bbb){
+ int xa = __builtin_isunordered(aaa, bbb);
+ int xb = __builtin_isunordered(bbb, bbb);
+ return xa | xb;
+}
+
+/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* unord aaa" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* unord bbb" "optimized" } } */
+/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* unord bbb" 2 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tree-optimization/63387] Recognize isunordered
2015-04-13 12:24 [tree-optimization/63387] Recognize isunordered Marc Glisse
@ 2015-04-13 12:36 ` Richard Biener
2015-04-13 13:11 ` Marc Glisse
0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2015-04-13 12:36 UTC (permalink / raw)
To: Marc Glisse; +Cc: GCC Patches
On Mon, Apr 13, 2015 at 2:23 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> Hello,
>
> just a simple pattern for match.pd. I am ignoring the issue of whether isnan
> is the same as isunordered, I am only combining isunordered together.
Ok.
Thanks,
Richard.
> 2015-04-13 Marc Glisse <marc.glisse@inria.fr>
>
> PR tree-optimization/63387
> gcc/
> * match.pd ((x unord x) | (y unord y) -> (x unord y),
> (x unord x) | (x unord y) -> (x unord y)): New simplifications.
> gcc/testsuite/
> * gcc.dg/pr63387.c: New testcase.
>
> --
> Marc Glisse
> Index: match.pd
> ===================================================================
> --- match.pd (revision 222041)
> +++ match.pd (working copy)
> @@ -925,20 +925,27 @@ along with GCC; see the file COPYING3.
> (ncmp @0 @1)))))
> (simplify
> (bit_xor (cmp @0 @1) integer_truep)
> (with { enum tree_code ic = invert_tree_comparison
> (cmp, HONOR_NANS (@0)); }
> (if (ic == icmp)
> (icmp @0 @1))
> (if (ic == ncmp)
> (ncmp @0 @1)))))
>
> +/* Unordered tests if either argument is a NaN. */
> +(simplify
> + (bit_ior (unordered @0 @0) (unordered @1 @1))
> + (unordered @0 @1))
> +(simplify
> + (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
> + @2)
>
> /* Simplification of math builtins. */
>
> (define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL)
> (define_operator_list EXP BUILT_IN_EXPF BUILT_IN_EXP BUILT_IN_EXPL)
> (define_operator_list LOG2 BUILT_IN_LOG2F BUILT_IN_LOG2 BUILT_IN_LOG2L)
> (define_operator_list EXP2 BUILT_IN_EXP2F BUILT_IN_EXP2 BUILT_IN_EXP2L)
> (define_operator_list LOG10 BUILT_IN_LOG10F BUILT_IN_LOG10 BUILT_IN_LOG10L)
> (define_operator_list EXP10 BUILT_IN_EXP10F BUILT_IN_EXP10 BUILT_IN_EXP10L)
> (define_operator_list POW BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL)
> Index: testsuite/gcc.dg/pr63387.c
> ===================================================================
> --- testsuite/gcc.dg/pr63387.c (revision 0)
> +++ testsuite/gcc.dg/pr63387.c (working copy)
> @@ -0,0 +1,19 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -fdump-tree-optimized" } */
> +
> +int f(double aaa, double bbb){
> + int xa = __builtin_isunordered(aaa, aaa);
> + int xb = __builtin_isunordered(bbb, bbb);
> + return xa | xb;
> +}
> +
> +int g(double aaa, double bbb){
> + int xa = __builtin_isunordered(aaa, bbb);
> + int xb = __builtin_isunordered(bbb, bbb);
> + return xa | xb;
> +}
> +
> +/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* unord aaa" "optimized" }
> } */
> +/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* unord bbb" "optimized" }
> } */
> +/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* unord bbb" 2
> "optimized" } } */
> +/* { dg-final { cleanup-tree-dump "optimized" } } */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tree-optimization/63387] Recognize isunordered
2015-04-13 12:36 ` Richard Biener
@ 2015-04-13 13:11 ` Marc Glisse
2015-04-13 21:37 ` Marc Glisse
0 siblings, 1 reply; 5+ messages in thread
From: Marc Glisse @ 2015-04-13 13:11 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches
On Mon, 13 Apr 2015, Richard Biener wrote:
> On Mon, Apr 13, 2015 at 2:23 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> Hello,
>>
>> just a simple pattern for match.pd. I am ignoring the issue of whether isnan
>> is the same as isunordered, I am only combining isunordered together.
>
> Ok.
Oups, I am an idiot. My own comment in bugzilla shows why the patch has a
bug, I'll post a fixed version soon. Sorry,
--
Marc Glisse
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tree-optimization/63387] Recognize isunordered
2015-04-13 13:11 ` Marc Glisse
@ 2015-04-13 21:37 ` Marc Glisse
2015-04-14 8:45 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Marc Glisse @ 2015-04-13 21:37 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches
[-- Attachment #1: Type: TEXT/PLAIN, Size: 706 bytes --]
On Mon, 13 Apr 2015, Marc Glisse wrote:
> On Mon, 13 Apr 2015, Richard Biener wrote:
>
>> On Mon, Apr 13, 2015 at 2:23 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
>>> Hello,
>>>
>>> just a simple pattern for match.pd. I am ignoring the issue of whether
>>> isnan
>>> is the same as isunordered, I am only combining isunordered together.
>>
>> Ok.
>
> Oups, I am an idiot. My own comment in bugzilla shows why the patch has a
> bug, I'll post a fixed version soon. Sorry,
Here is the fixed patch (same ChangeLog).
I copied the type compatibility check from other places in match.pd, it
would be a good idea to provide a helper to avoid repeating this code.
Is the new version ok?
--
Marc Glisse
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2535 bytes --]
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 222062)
+++ gcc/match.pd (working copy)
@@ -925,20 +925,29 @@ along with GCC; see the file COPYING3.
(ncmp @0 @1)))))
(simplify
(bit_xor (cmp @0 @1) integer_truep)
(with { enum tree_code ic = invert_tree_comparison
(cmp, HONOR_NANS (@0)); }
(if (ic == icmp)
(icmp @0 @1))
(if (ic == ncmp)
(ncmp @0 @1)))))
+/* Unordered tests if either argument is a NaN. */
+(simplify
+ (bit_ior (unordered @0 @0) (unordered @1 @1))
+ (if ((GIMPLE && types_compatible_p (TREE_TYPE (@0), TREE_TYPE (@1)))
+ || (GENERIC && TREE_TYPE (@0) == TREE_TYPE (@1)))
+ (unordered @0 @1)))
+(simplify
+ (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
+ @2)
/* Simplification of math builtins. */
(define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL)
(define_operator_list EXP BUILT_IN_EXPF BUILT_IN_EXP BUILT_IN_EXPL)
(define_operator_list LOG2 BUILT_IN_LOG2F BUILT_IN_LOG2 BUILT_IN_LOG2L)
(define_operator_list EXP2 BUILT_IN_EXP2F BUILT_IN_EXP2 BUILT_IN_EXP2L)
(define_operator_list LOG10 BUILT_IN_LOG10F BUILT_IN_LOG10 BUILT_IN_LOG10L)
(define_operator_list EXP10 BUILT_IN_EXP10F BUILT_IN_EXP10 BUILT_IN_EXP10L)
(define_operator_list POW BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL)
Index: gcc/testsuite/gcc.dg/pr63387.c
===================================================================
--- gcc/testsuite/gcc.dg/pr63387.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr63387.c (working copy)
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+int f(double aaa, double bbb){
+ int xa = __builtin_isunordered(aaa, aaa);
+ int xb = __builtin_isunordered(bbb, bbb);
+ return xa | xb;
+}
+
+int g(double aaa, double bbb){
+ int xa = __builtin_isunordered(aaa, bbb);
+ int xb = __builtin_isunordered(bbb, bbb);
+ return xa | xb;
+}
+
+int h(double ccc, float ddd){
+ int xc = __builtin_isunordered(ccc, ccc);
+ int xd = __builtin_isunordered(ddd, ddd);
+ return xc | xd;
+}
+
+/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* unord aaa" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* unord bbb" "optimized" } } */
+/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* unord bbb" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "ccc\[^\n\r\]* unord ddd" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tree-optimization/63387] Recognize isunordered
2015-04-13 21:37 ` Marc Glisse
@ 2015-04-14 8:45 ` Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2015-04-14 8:45 UTC (permalink / raw)
To: Marc Glisse; +Cc: GCC Patches
On Mon, Apr 13, 2015 at 11:37 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Mon, 13 Apr 2015, Marc Glisse wrote:
>
>> On Mon, 13 Apr 2015, Richard Biener wrote:
>>
>>> On Mon, Apr 13, 2015 at 2:23 PM, Marc Glisse <marc.glisse@inria.fr>
>>> wrote:
>>>>
>>>> Hello,
>>>>
>>>> just a simple pattern for match.pd. I am ignoring the issue of whether
>>>> isnan
>>>> is the same as isunordered, I am only combining isunordered together.
>>>
>>>
>>> Ok.
>>
>>
>> Oups, I am an idiot. My own comment in bugzilla shows why the patch has a
>> bug, I'll post a fixed version soon. Sorry,
>
>
> Here is the fixed patch (same ChangeLog).
>
> I copied the type compatibility check from other places in match.pd, it
> would be a good idea to provide a helper to avoid repeating this code.
Agreed and on my list of cleanups ...
> Is the new version ok?
Ok if bootstrapped / tested.
Thanks,
Richard.
> --
> Marc Glisse
> Index: gcc/match.pd
> ===================================================================
> --- gcc/match.pd (revision 222062)
> +++ gcc/match.pd (working copy)
> @@ -925,20 +925,29 @@ along with GCC; see the file COPYING3.
> (ncmp @0 @1)))))
> (simplify
> (bit_xor (cmp @0 @1) integer_truep)
> (with { enum tree_code ic = invert_tree_comparison
> (cmp, HONOR_NANS (@0)); }
> (if (ic == icmp)
> (icmp @0 @1))
> (if (ic == ncmp)
> (ncmp @0 @1)))))
>
> +/* Unordered tests if either argument is a NaN. */
> +(simplify
> + (bit_ior (unordered @0 @0) (unordered @1 @1))
> + (if ((GIMPLE && types_compatible_p (TREE_TYPE (@0), TREE_TYPE (@1)))
> + || (GENERIC && TREE_TYPE (@0) == TREE_TYPE (@1)))
> + (unordered @0 @1)))
> +(simplify
> + (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
> + @2)
>
> /* Simplification of math builtins. */
>
> (define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL)
> (define_operator_list EXP BUILT_IN_EXPF BUILT_IN_EXP BUILT_IN_EXPL)
> (define_operator_list LOG2 BUILT_IN_LOG2F BUILT_IN_LOG2 BUILT_IN_LOG2L)
> (define_operator_list EXP2 BUILT_IN_EXP2F BUILT_IN_EXP2 BUILT_IN_EXP2L)
> (define_operator_list LOG10 BUILT_IN_LOG10F BUILT_IN_LOG10 BUILT_IN_LOG10L)
> (define_operator_list EXP10 BUILT_IN_EXP10F BUILT_IN_EXP10 BUILT_IN_EXP10L)
> (define_operator_list POW BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL)
> Index: gcc/testsuite/gcc.dg/pr63387.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pr63387.c (revision 0)
> +++ gcc/testsuite/gcc.dg/pr63387.c (working copy)
> @@ -0,0 +1,26 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -fdump-tree-optimized" } */
> +
> +int f(double aaa, double bbb){
> + int xa = __builtin_isunordered(aaa, aaa);
> + int xb = __builtin_isunordered(bbb, bbb);
> + return xa | xb;
> +}
> +
> +int g(double aaa, double bbb){
> + int xa = __builtin_isunordered(aaa, bbb);
> + int xb = __builtin_isunordered(bbb, bbb);
> + return xa | xb;
> +}
> +
> +int h(double ccc, float ddd){
> + int xc = __builtin_isunordered(ccc, ccc);
> + int xd = __builtin_isunordered(ddd, ddd);
> + return xc | xd;
> +}
> +
> +/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* unord aaa" "optimized" }
> } */
> +/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* unord bbb" "optimized" }
> } */
> +/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* unord bbb" 2
> "optimized" } } */
> +/* { dg-final { scan-tree-dump-not "ccc\[^\n\r\]* unord ddd" "optimized" }
> } */
> +/* { dg-final { cleanup-tree-dump "optimized" } } */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-14 8:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 12:24 [tree-optimization/63387] Recognize isunordered Marc Glisse
2015-04-13 12:36 ` Richard Biener
2015-04-13 13:11 ` Marc Glisse
2015-04-13 21:37 ` Marc Glisse
2015-04-14 8:45 ` 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).