Message ID | alpine.DEB.2.02.1604302026470.16157@laptop-mg.saclay.inria.fr |
---|---|
State | New |
Headers | show |
On Sat, Apr 30, 2016 at 8:44 PM, Marc Glisse <marc.glisse@inria.fr> wrote: > Hello, > > this case seemed to be missing in the various X cmp X transformations. It > does not change the generated code in the testcase. > > The missing :c is rather trivial. I can commit it separately if you prefer. I think it's not missing. Commutating the first one is enough to eventually make the @1s match up. I think you should get a diagnostic on a duplicate pattern when adding another :c (hmm, no, it's indeed "different" patterns but still redundant). > Bootstrap+regtest on powerpc64le-unknown-linux-gnu. Ok for the new pattern. Thanks, Richard. > 2016-05-02 Marc Glisse <marc.glisse@inria.fr> > > gcc/ > * match.pd ((A & B) OP (C & B)): Mark '&' as commutative. > (X u< X, X u> X): New transformations > > gcc/testsuite/ > * gcc.dg/tree-ssa/unord.c: New testcase. > > -- > Marc Glisse > Index: trunk/gcc/match.pd > =================================================================== > --- trunk/gcc/match.pd (revision 235654) > +++ trunk/gcc/match.pd (working copy) > @@ -783,21 +783,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > @0) > /* (~x | y) & x -> x & y */ > /* (~x & y) | x -> x | y */ > (simplify > (bitop:c (rbitop:c (bit_not @0) @1) @0) > (bitop @0 @1))) > > /* Simplify (A & B) OP0 (C & B) to (A OP0 C) & B. */ > (for bitop (bit_and bit_ior bit_xor) > (simplify > - (bitop (bit_and:c @0 @1) (bit_and @2 @1)) > + (bitop (bit_and:c @0 @1) (bit_and:c @2 @1)) > (bit_and (bitop @0 @2) @1))) > > /* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */ > (simplify > (bit_and (bit_ior @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2) > (bit_ior (bit_and @0 @2) (bit_and @1 @2))) > > /* Combine successive equal operations with constants. */ > (for bitop (bit_and bit_ior bit_xor) > (simplify > @@ -1914,20 +1914,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (simplify > (cmp @0 @0) > (if (cmp != NE_EXPR > || ! FLOAT_TYPE_P (TREE_TYPE (@0)) > || ! HONOR_NANS (@0)) > { constant_boolean_node (false, type); }))) > (for cmp (unle unge uneq) > (simplify > (cmp @0 @0) > { constant_boolean_node (true, type); })) > +(for cmp (unlt ungt) > + (simplify > + (cmp @0 @0) > + (unordered @0 @0))) > (simplify > (ltgt @0 @0) > (if (!flag_trapping_math) > { constant_boolean_node (false, type); })) > > /* Fold ~X op ~Y as Y op X. */ > (for cmp (simple_comparison) > (simplify > (cmp (bit_not@2 @0) (bit_not@3 @1)) > (if (single_use (@2) && single_use (@3)) > Index: trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c > =================================================================== > --- trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (revision 0) > +++ trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (working copy) > @@ -0,0 +1,7 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O -fdump-tree-optimized" } */ > + > +int f(double a){double b=a;return !__builtin_islessequal(a,b);} > +int g(double a){double b=a;return !__builtin_isgreaterequal(a,b);} > + > +/* { dg-final { scan-tree-dump-times " unord " 2 "optimized" } } */ >
On Mon, 2 May 2016, Richard Biener wrote: > On Sat, Apr 30, 2016 at 8:44 PM, Marc Glisse <marc.glisse@inria.fr> wrote: >> Hello, >> >> this case seemed to be missing in the various X cmp X transformations. It >> does not change the generated code in the testcase. >> >> The missing :c is rather trivial. I can commit it separately if you prefer. > > I think it's not missing. Commutating the first one is enough to eventually > make the @1s match up. I think you should get a diagnostic on a duplicate > pattern when adding another :c (hmm, no, it's indeed "different" patterns but > still redundant). Let's see. The current pattern is (bitop (bit_and:c @0 @1) (bit_and @2 @1)) This matches: (X & Y) ^ (Z & Y) (Y & X) ^ (Z & Y) If I have for instance (Y & X) ^ (Y & Z), I don't see how that is going to match, and indeed we don't simplify that. On the other hand, if I have bit_ior instead of bit_xor, then we have another very similar transformation a 100 lines up in match.pd (for op (bit_and bit_ior) rop (bit_ior bit_and) (simplify (op (convert? (rop:c @0 @1)) (convert? (rop @0 @2))) That one also commutes only one, but starting from a different match. We should probably reorganize them a bit. >> Bootstrap+regtest on powerpc64le-unknown-linux-gnu. > > Ok for the new pattern. > > Thanks, > Richard. > >> 2016-05-02 Marc Glisse <marc.glisse@inria.fr> >> >> gcc/ >> * match.pd ((A & B) OP (C & B)): Mark '&' as commutative. >> (X u< X, X u> X): New transformations >> >> gcc/testsuite/ >> * gcc.dg/tree-ssa/unord.c: New testcase. >> >> -- >> Marc Glisse >> Index: trunk/gcc/match.pd >> =================================================================== >> --- trunk/gcc/match.pd (revision 235654) >> +++ trunk/gcc/match.pd (working copy) >> @@ -783,21 +783,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >> @0) >> /* (~x | y) & x -> x & y */ >> /* (~x & y) | x -> x | y */ >> (simplify >> (bitop:c (rbitop:c (bit_not @0) @1) @0) >> (bitop @0 @1))) >> >> /* Simplify (A & B) OP0 (C & B) to (A OP0 C) & B. */ >> (for bitop (bit_and bit_ior bit_xor) >> (simplify >> - (bitop (bit_and:c @0 @1) (bit_and @2 @1)) >> + (bitop (bit_and:c @0 @1) (bit_and:c @2 @1)) >> (bit_and (bitop @0 @2) @1))) >> >> /* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */ >> (simplify >> (bit_and (bit_ior @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2) >> (bit_ior (bit_and @0 @2) (bit_and @1 @2))) >> >> /* Combine successive equal operations with constants. */ >> (for bitop (bit_and bit_ior bit_xor) >> (simplify >> @@ -1914,20 +1914,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >> (simplify >> (cmp @0 @0) >> (if (cmp != NE_EXPR >> || ! FLOAT_TYPE_P (TREE_TYPE (@0)) >> || ! HONOR_NANS (@0)) >> { constant_boolean_node (false, type); }))) >> (for cmp (unle unge uneq) >> (simplify >> (cmp @0 @0) >> { constant_boolean_node (true, type); })) >> +(for cmp (unlt ungt) >> + (simplify >> + (cmp @0 @0) >> + (unordered @0 @0))) >> (simplify >> (ltgt @0 @0) >> (if (!flag_trapping_math) >> { constant_boolean_node (false, type); })) >> >> /* Fold ~X op ~Y as Y op X. */ >> (for cmp (simple_comparison) >> (simplify >> (cmp (bit_not@2 @0) (bit_not@3 @1)) >> (if (single_use (@2) && single_use (@3)) >> Index: trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c >> =================================================================== >> --- trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (revision 0) >> +++ trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (working copy) >> @@ -0,0 +1,7 @@ >> +/* { dg-do compile } */ >> +/* { dg-options "-O -fdump-tree-optimized" } */ >> + >> +int f(double a){double b=a;return !__builtin_islessequal(a,b);} >> +int g(double a){double b=a;return !__builtin_isgreaterequal(a,b);} >> + >> +/* { dg-final { scan-tree-dump-times " unord " 2 "optimized" } } */
On Mon, May 2, 2016 at 11:18 AM, Marc Glisse <marc.glisse@inria.fr> wrote: > On Mon, 2 May 2016, Richard Biener wrote: > >> On Sat, Apr 30, 2016 at 8:44 PM, Marc Glisse <marc.glisse@inria.fr> wrote: >>> >>> Hello, >>> >>> this case seemed to be missing in the various X cmp X transformations. It >>> does not change the generated code in the testcase. >>> >>> The missing :c is rather trivial. I can commit it separately if you >>> prefer. >> >> >> I think it's not missing. Commutating the first one is enough to >> eventually >> make the @1s match up. I think you should get a diagnostic on a duplicate >> pattern when adding another :c (hmm, no, it's indeed "different" patterns >> but >> still redundant). > > > Let's see. The current pattern is > (bitop (bit_and:c @0 @1) (bit_and @2 @1)) > > This matches: > (X & Y) ^ (Z & Y) > (Y & X) ^ (Z & Y) > > If I have for instance (Y & X) ^ (Y & Z), I don't see how that is going to > match, and indeed we don't simplify that. Hmm, indeed. I might have wrongly ommitted some :c then in other places as well. So the original patch is ok. > On the other hand, if I have > bit_ior instead of bit_xor, then we have another very similar transformation > a 100 lines up in match.pd > > (for op (bit_and bit_ior) > rop (bit_ior bit_and) > (simplify > (op (convert? (rop:c @0 @1)) (convert? (rop @0 @2))) > > That one also commutes only one, but starting from a different match. We > should probably reorganize them a bit. Yeah. Richard. > >>> Bootstrap+regtest on powerpc64le-unknown-linux-gnu. >> >> >> Ok for the new pattern. >> >> Thanks, >> Richard. >> >>> 2016-05-02 Marc Glisse <marc.glisse@inria.fr> >>> >>> gcc/ >>> * match.pd ((A & B) OP (C & B)): Mark '&' as commutative. >>> (X u< X, X u> X): New transformations >>> >>> gcc/testsuite/ >>> * gcc.dg/tree-ssa/unord.c: New testcase. >>> >>> -- >>> Marc Glisse >>> Index: trunk/gcc/match.pd >>> =================================================================== >>> --- trunk/gcc/match.pd (revision 235654) >>> +++ trunk/gcc/match.pd (working copy) >>> @@ -783,21 +783,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >>> @0) >>> /* (~x | y) & x -> x & y */ >>> /* (~x & y) | x -> x | y */ >>> (simplify >>> (bitop:c (rbitop:c (bit_not @0) @1) @0) >>> (bitop @0 @1))) >>> >>> /* Simplify (A & B) OP0 (C & B) to (A OP0 C) & B. */ >>> (for bitop (bit_and bit_ior bit_xor) >>> (simplify >>> - (bitop (bit_and:c @0 @1) (bit_and @2 @1)) >>> + (bitop (bit_and:c @0 @1) (bit_and:c @2 @1)) >>> (bit_and (bitop @0 @2) @1))) >>> >>> /* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */ >>> (simplify >>> (bit_and (bit_ior @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2) >>> (bit_ior (bit_and @0 @2) (bit_and @1 @2))) >>> >>> /* Combine successive equal operations with constants. */ >>> (for bitop (bit_and bit_ior bit_xor) >>> (simplify >>> @@ -1914,20 +1914,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >>> (simplify >>> (cmp @0 @0) >>> (if (cmp != NE_EXPR >>> || ! FLOAT_TYPE_P (TREE_TYPE (@0)) >>> || ! HONOR_NANS (@0)) >>> { constant_boolean_node (false, type); }))) >>> (for cmp (unle unge uneq) >>> (simplify >>> (cmp @0 @0) >>> { constant_boolean_node (true, type); })) >>> +(for cmp (unlt ungt) >>> + (simplify >>> + (cmp @0 @0) >>> + (unordered @0 @0))) >>> (simplify >>> (ltgt @0 @0) >>> (if (!flag_trapping_math) >>> { constant_boolean_node (false, type); })) >>> >>> /* Fold ~X op ~Y as Y op X. */ >>> (for cmp (simple_comparison) >>> (simplify >>> (cmp (bit_not@2 @0) (bit_not@3 @1)) >>> (if (single_use (@2) && single_use (@3)) >>> Index: trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c >>> =================================================================== >>> --- trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (revision 0) >>> +++ trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (working copy) >>> @@ -0,0 +1,7 @@ >>> +/* { dg-do compile } */ >>> +/* { dg-options "-O -fdump-tree-optimized" } */ >>> + >>> +int f(double a){double b=a;return !__builtin_islessequal(a,b);} >>> +int g(double a){double b=a;return !__builtin_isgreaterequal(a,b);} >>> + >>> +/* { dg-final { scan-tree-dump-times " unord " 2 "optimized" } } */ > > > -- > Marc Glisse
Index: trunk/gcc/match.pd =================================================================== --- trunk/gcc/match.pd (revision 235654) +++ trunk/gcc/match.pd (working copy) @@ -783,21 +783,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) @0) /* (~x | y) & x -> x & y */ /* (~x & y) | x -> x | y */ (simplify (bitop:c (rbitop:c (bit_not @0) @1) @0) (bitop @0 @1))) /* Simplify (A & B) OP0 (C & B) to (A OP0 C) & B. */ (for bitop (bit_and bit_ior bit_xor) (simplify - (bitop (bit_and:c @0 @1) (bit_and @2 @1)) + (bitop (bit_and:c @0 @1) (bit_and:c @2 @1)) (bit_and (bitop @0 @2) @1))) /* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */ (simplify (bit_and (bit_ior @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2) (bit_ior (bit_and @0 @2) (bit_and @1 @2))) /* Combine successive equal operations with constants. */ (for bitop (bit_and bit_ior bit_xor) (simplify @@ -1914,20 +1914,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (cmp @0 @0) (if (cmp != NE_EXPR || ! FLOAT_TYPE_P (TREE_TYPE (@0)) || ! HONOR_NANS (@0)) { constant_boolean_node (false, type); }))) (for cmp (unle unge uneq) (simplify (cmp @0 @0) { constant_boolean_node (true, type); })) +(for cmp (unlt ungt) + (simplify + (cmp @0 @0) + (unordered @0 @0))) (simplify (ltgt @0 @0) (if (!flag_trapping_math) { constant_boolean_node (false, type); })) /* Fold ~X op ~Y as Y op X. */ (for cmp (simple_comparison) (simplify (cmp (bit_not@2 @0) (bit_not@3 @1)) (if (single_use (@2) && single_use (@3)) Index: trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c =================================================================== --- trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (revision 0) +++ trunk/gcc/testsuite/gcc.dg/tree-ssa/unord.c (working copy) @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +int f(double a){double b=a;return !__builtin_islessequal(a,b);} +int g(double a){double b=a;return !__builtin_isgreaterequal(a,b);} + +/* { dg-final { scan-tree-dump-times " unord " 2 "optimized" } } */