Re: [PATCH][match-and-simplify] Hande side-effects in GENERIC

2014-10-22 Thread Richard Biener
On October 22, 2014 5:08:50 PM CEST, Jakub Jelinek wrote: >On Wed, Oct 22, 2014 at 04:20:09PM +0200, Richard Biener wrote: >> 2014-10-22 Richard Biener >> >> * genmatch.c (count_captures): New function. >> (dt_simplify::gen): Handle preserving side-effects for >> GENERIC code ge

Re: [PATCH][match-and-simplify] Hande side-effects in GENERIC

2014-10-22 Thread Jakub Jelinek
On Wed, Oct 22, 2014 at 04:20:09PM +0200, Richard Biener wrote: > 2014-10-22 Richard Biener > > * genmatch.c (count_captures): New function. > (dt_simplify::gen): Handle preserving side-effects for > GENERIC code generation. > (decision_tree::gen_generic): Do not reject

Re: [PATCH][match-and-simplify] Hande side-effects in GENERIC

2014-10-22 Thread Richard Biener
On Wed, 22 Oct 2014, Richard Biener wrote: > > The following auto-handles preserving of side-effects properly > for GENERIC simplification instead of simply rejecting operands > with side-effects. Cases we cannot handle correctly are still > handled that way. > > For example for > > /* (x | CS

Re: [PATCH][match-and-simplify] More ternary commutative ops, canonicalize operand order before generic_simplify

2014-10-17 Thread Richard Biener
On Fri, 17 Oct 2014, Richard Biener wrote: > On Thu, 16 Oct 2014, Jeff Law wrote: > > > On 10/16/14 05:06, Richard Biener wrote: > > > > > > This patch (also applicable to trunk) makes us canoncialize operand > > > order for comparisons at the same time we canonicalize other > > > operand order,

Re: [PATCH][match-and-simplify] More ternary commutative ops, canonicalize operand order before generic_simplify

2014-10-17 Thread Richard Biener
On Thu, 16 Oct 2014, Jeff Law wrote: > On 10/16/14 05:06, Richard Biener wrote: > > > > This patch (also applicable to trunk) makes us canoncialize operand > > order for comparisons at the same time we canonicalize other > > operand order, in particular before dispatching to generic_simplify. > >

Re: [PATCH][match-and-simplify] More ternary commutative ops, canonicalize operand order before generic_simplify

2014-10-16 Thread Jeff Law
On 10/16/14 05:06, Richard Biener wrote: This patch (also applicable to trunk) makes us canoncialize operand order for comparisons at the same time we canonicalize other operand order, in particular before dispatching to generic_simplify. It also adds operand canonicalization to ternary ops and

Re: [PATCH][match-and-simplify] Change back default behavior of fold_stmt

2014-10-14 Thread Richard Biener
On Tue, 14 Oct 2014, Richard Biener wrote: > On Tue, 14 Oct 2014, Richard Biener wrote: > > > > > This changes default behavior of fold_stmt back to _not_ following > > SSA use-def chains when trying to simplify things. I had to force > > that already for one caller and for the merge to trunk I

Re: [PATCH][match-and-simplify] Change back default behavior of fold_stmt

2014-10-14 Thread Richard Biener
On Tue, 14 Oct 2014, Richard Biener wrote: > > This changes default behavior of fold_stmt back to _not_ following > SSA use-def chains when trying to simplify things. I had to force > that already for one caller and for the merge to trunk I'd rather > not track down issues in every other existin

Re: [PATCH][match-and-simplify] Enable conversions properly for GENERIC

2014-09-26 Thread Jason Merrill
On 09/26/2014 06:54 AM, Richard Biener wrote: It also uncovers that the C++ FE uses a mix of NOP_EXPR and CONVERT_EXPR both when building expressions and when checking for them. Jason - is there any difference between NOP_EXPR and CONVERT_EXPR as far as the C++ FE is concerned? There are a few

Re: [PATCH][match-and-simplify] User defined predicates

2014-09-22 Thread Richard Biener
On Tue, 16 Sep 2014, Marc Glisse wrote: > On Tue, 16 Sep 2014, Richard Biener wrote: > > > The following adds the ability to write predicates using patterns > > with an example following negate_expr_p which already has a > > use in comparison folding (via its if c-expr). > > > > The syntax is as

Re: [PATCH][match-and-simplify] User defined predicates

2014-09-16 Thread Marc Glisse
On Tue, 16 Sep 2014, Richard Biener wrote: The following adds the ability to write predicates using patterns with an example following negate_expr_p which already has a use in comparison folding (via its if c-expr). The syntax is as follows: (match negate_expr_p INTEGER_CST (if (TYPE_OVERFLOW_

Re: [PATCH][match-and-simplify] Finish simplify_bitwise_binary patterns

2014-09-12 Thread Richard Biener
On Fri, 12 Sep 2014, Marc Glisse wrote: > On Fri, 12 Sep 2014, Richard Biener wrote: > > > +/* x ^ ~0 -> ~x */ > > (simplify > > (bit_and @0 integer_all_onesp) > > @0) > > The comment doesn't seem to match. Thanks - fixed below which also implements simplify_mult and simplify_not_neg_expr.

Re: [PATCH][match-and-simplify] Finish simplify_bitwise_binary patterns

2014-09-12 Thread Marc Glisse
On Fri, 12 Sep 2014, Richard Biener wrote: +/* x ^ ~0 -> ~x */ (simplify (bit_and @0 integer_all_onesp) @0) The comment doesn't seem to match. -- Marc Glisse

Re: [PATCH][match-and-simplify] Minor fixes to match-plusminus.pd

2014-09-11 Thread Richard Biener
On Thu, 11 Sep 2014, Marc Glisse wrote: > /* ~A + 1 -> -A */ > (simplify >(plus (bit_not @0) integer_onep@1) >(if (TREE_CODE (TREE_TYPE (@1)) != COMPLEX_TYPE > || (TREE_CODE (@1) == COMPLEX_CST > && integer_onep (TREE_REALPART (@1)) > && integer_onep (TR

Re: [PATCH][match-and-simplify] Minor fixes to match-plusminus.pd

2014-09-11 Thread Marc Glisse
/* ~A + 1 -> -A */ (simplify (plus (bit_not @0) integer_onep@1) (if (TREE_CODE (TREE_TYPE (@1)) != COMPLEX_TYPE || (TREE_CODE (@1) == COMPLEX_CST && integer_onep (TREE_REALPART (@1)) && integer_onep (TREE_IMAGPART (@1 (negate @0))) the complex par

Re: [PATCH][match-and-simplify] Complete associate_* patterns

2014-09-11 Thread Richard Biener
On Thu, 11 Sep 2014, Marc Glisse wrote: > On Thu, 11 Sep 2014, Richard Biener wrote: > > > + /* We can't reassociate floating-point or fixed-point plus or minus > > +because of saturation to +-Inf. */ > > + (if (!FLOAT_TYPE_P (type) && !FIXED_POINT_TYPE_P (type)) > > Do you remember if ther

Re: [PATCH][match-and-simplify] Complete associate_* patterns

2014-09-11 Thread Marc Glisse
On Thu, 11 Sep 2014, Richard Biener wrote: + /* We can't reassociate floating-point or fixed-point plus or minus +because of saturation to +-Inf. */ + (if (!FLOAT_TYPE_P (type) && !FIXED_POINT_TYPE_P (type)) Do you remember if there was a particular reason not to add || flag_associative

Re: [PATCH][match-and-simplify] Auto-guess conversion types

2014-08-26 Thread Richard Biener
On Thu, 21 Aug 2014, Marc Glisse wrote: > On Thu, 21 Aug 2014, Richard Biener wrote: > > > 2014-08-21 Richard Biener > > > > * match.pd ((T1)(~(T2) X) -> ~(T1) X): Paste all comment > > from fold-const.c, fix simplification result. > > > > Index: gcc/match.pd > >

Re: [PATCH][match-and-simplify] Auto-guess conversion types

2014-08-21 Thread Marc Glisse
On Thu, 21 Aug 2014, Richard Biener wrote: 2014-08-21 Richard Biener * match.pd ((T1)(~(T2) X) -> ~(T1) X): Paste all comment from fold-const.c, fix simplification result. Index: gcc/match.pd === --- gcc/match.p

Re: [PATCH][match-and-simplify] Auto-guess conversion types

2014-08-21 Thread Richard Biener
On Thu, 21 Aug 2014, Marc Glisse wrote: > On Thu, 21 Aug 2014, Richard Biener wrote: > > > +/* From fold_unary. */ > > + > > +/* (T1)(~(T2) X) -> ~(T1) X */ > > +(simplify > > + (convert (bit_not@0 (convert @1))) > > + (if (INTEGRAL_TYPE_P (type) > > + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) >

Re: [PATCH][match-and-simplify] Auto-guess conversion types

2014-08-21 Thread Marc Glisse
On Thu, 21 Aug 2014, Richard Biener wrote: +/* From fold_unary. */ + +/* (T1)(~(T2) X) -> ~(T1) X */ +(simplify + (convert (bit_not@0 (convert @1))) + (if (INTEGRAL_TYPE_P (type) + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (@0)) +

Re: [PATCH][match-and-simplify] Fix comparison pattern

2014-08-20 Thread Richard Biener
On Wed, 20 Aug 2014, Marc Glisse wrote: > On Wed, 20 Aug 2014, Richard Biener wrote: > > > On Wed, 20 Aug 2014, Marc Glisse wrote: > > > > > On Wed, 20 Aug 2014, Richard Biener wrote: > > > > > > > Committed. > > > > > > > > Also makes visible a desirable change I plan for if-exprs. They > >

Re: [PATCH][match-and-simplify] Fix comparison pattern

2014-08-20 Thread Marc Glisse
On Wed, 20 Aug 2014, Richard Biener wrote: On Wed, 20 Aug 2014, Marc Glisse wrote: On Wed, 20 Aug 2014, Richard Biener wrote: Committed. Also makes visible a desirable change I plan for if-exprs. They should behave like outer ifs and allow us to write that series of pattern as (for op in

Re: [PATCH][match-and-simplify] Fix comparison pattern

2014-08-20 Thread Richard Biener
On Wed, 20 Aug 2014, Marc Glisse wrote: > On Wed, 20 Aug 2014, Richard Biener wrote: > > > Committed. > > > > Also makes visible a desirable change I plan for if-exprs. They > > should behave like outer ifs and allow us to write that series > > of pattern as > > > > (for op in eq ne > > /* Si

Re: [PATCH][match-and-simplify] Fix comparison pattern

2014-08-20 Thread Marc Glisse
On Wed, 20 Aug 2014, Richard Biener wrote: Committed. Also makes visible a desirable change I plan for if-exprs. They should behave like outer ifs and allow us to write that series of pattern as (for op in eq ne /* Simplify X * C1 CMP 0 to X CMP 0 if C1 is not zero. */ (simplify (op (mu

Re: [PATCH][match-and-simplify] Mark conditional converts with '?'

2014-08-12 Thread Richard Biener
On Tue, 12 Aug 2014, Jakub Jelinek wrote: > On Tue, Aug 12, 2014 at 12:15:20PM +0200, Richard Biener wrote: > > @@ -2422,6 +2441,7 @@ main(int argc, char **argv) > >add_operator (SYM, # SYM, # TYPE, NARGS); > > #define END_OF_BASE_TREE_CODES > > #include "tree.def" > > +add_operator (CONVERT

Re: [PATCH][match-and-simplify] Mark conditional converts with '?'

2014-08-12 Thread Jakub Jelinek
On Tue, Aug 12, 2014 at 12:15:20PM +0200, Richard Biener wrote: > @@ -2422,6 +2441,7 @@ main(int argc, char **argv) >add_operator (SYM, # SYM, # TYPE, NARGS); > #define END_OF_BASE_TREE_CODES > #include "tree.def" > +add_operator (CONVERT1, "CONVERT0", "tcc_unary", 1); Pasto? Shouldn't that

Re: [PATCH][match-and-simplify] Implement two-parameter builtin-function simplify

2014-08-06 Thread Richard Biener
On Wed, 6 Aug 2014, Richard Biener wrote: > > $subject, applied. Err, too fast. Fixed. Richard. 2014-08-06 Richard Biener * gimple-match-head.c (gimple_simplify): Fix implementation. Index: gcc/gimple-match-head.c ==

Re: [PATCH][match-and-simplify] Fix remaining testsuite ICEs

2014-08-06 Thread Richard Biener
On Wed, 6 Aug 2014, Richard Biener wrote: > > The following fixes the remaining ICEs I see when testing all > languages (but ada and go). > > The tree-cfg.c hunk highlights one change in the behavior > of fold_stmt, namely that it now follows SSA edges by default. > Maybe that's undesired? On a

Re: [PATCH][match-and-simplify] GENERIC code-gen

2014-06-25 Thread Richard Biener
On Tue, 24 Jun 2014, Prathamesh Kulkarni wrote: > On Tue, Jun 24, 2014 at 9:00 PM, Richard Biener wrote: > > > > This massages things so GENERIC code-gen works (well, is emitted > > and compiles). The GENERIC interface matches that of > > fold_{unary,binary,ternary} with also supporting calls he

Re: [PATCH][match-and-simplify] GENERIC code-gen

2014-06-24 Thread Prathamesh Kulkarni
On Tue, Jun 24, 2014 at 9:00 PM, Richard Biener wrote: > > This massages things so GENERIC code-gen works (well, is emitted > and compiles). The GENERIC interface matches that of > fold_{unary,binary,ternary} with also supporting calls here. > It's supposed to be called at the start of those func

Re: [PATCH][match-and-simplify] Annotate generated source with line directives

2014-06-05 Thread Richard Biener
On Thu, 5 Jun 2014, Richard Earnshaw wrote: > On 05/06/14 14:25, Richard Biener wrote: > > > > The following makes genmatch annotate gimple-match.c with (commented > > for now) line directives, similar to other generator programs. > > This should help associating generated code with parts in matc

Re: [PATCH][match-and-simplify] Annotate generated source with line directives

2014-06-05 Thread Richard Earnshaw
On 05/06/14 14:25, Richard Biener wrote: > > The following makes genmatch annotate gimple-match.c with (commented > for now) line directives, similar to other generator programs. > This should help associating generated code with parts in match.pd. > I've often found these annotations more of a

Re: [PATCH][match-and-simplify]

2014-06-03 Thread Richard Biener
On Tue, 3 Jun 2014, Marc Glisse wrote: > On Tue, 3 Jun 2014, Richard Biener wrote: > > > On Mon, 2 Jun 2014, Marc Glisse wrote: > > > > > > > > >(plus (bit_not @0) @0) > > > >if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) > > > >{ build_int_cst (TREE_TYPE (@0), -1); }) > > > > +(match_and_si

Re: [PATCH][match-and-simplify]

2014-06-03 Thread Marc Glisse
On Tue, 3 Jun 2014, Richard Biener wrote: On Mon, 2 Jun 2014, Marc Glisse wrote: (plus (bit_not @0) @0) if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) { build_int_cst (TREE_TYPE (@0), -1); }) +(match_and_simplify + (plus @0 (bit_not @0)) + if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) + { build_i

Re: [PATCH][match-and-simplify]

2014-06-03 Thread Richard Biener
On Mon, 2 Jun 2014, Marc Glisse wrote: > > >(plus (bit_not @0) @0) > >if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) > >{ build_int_cst (TREE_TYPE (@0), -1); }) > > +(match_and_simplify > > + (plus @0 (bit_not @0)) > > + if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) > > + { build_int_cst (TREE_TYPE

Re: [PATCH][match-and-simplify]

2014-06-02 Thread Marc Glisse
(plus (bit_not @0) @0) if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) { build_int_cst (TREE_TYPE (@0), -1); }) +(match_and_simplify + (plus @0 (bit_not @0)) + if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) + { build_int_cst (TREE_TYPE (@0), -1); }) Why not just: (match_and_simplify (plus @0 (bit_