diff mbox

Remove match.pd pattern dups in favor of using :c

Message ID alpine.LNX.2.20.1606101526150.24216@monopod.intra.ispras.ru
State New
Headers show

Commit Message

Alexander Monakov June 10, 2016, 12:29 p.m. UTC
On Wed, 1 Jun 2016, Richard Biener wrote:
> > On Wed, 1 Jun 2016, Richard Biener wrote:
> > > 2016-06-01  Richard Biener  <rguenther@suse.de>
> > > 
> > > 	* match.pd ((A & B) - (A & ~B) -> B - (A ^ B)): Add missing :c.
> > > 	(relational patterns): Use :c to avoid pattern duplications.
> > 
> > Should the same treatment be applied to recently added IFN_MUL_OVERFLOW
> > patterns (lines 2625-2643 in current match.pd)?
> 
> Ah, yeah - I missed those appearantly.

Here's a patch. Bootstrapped/regtested on x86_64, OK to apply?

Thanks.
Alexander

	* match.pd (-1 / B < A): Use :c to avoid pattern duplication.

Comments

Richard Biener June 10, 2016, 12:43 p.m. UTC | #1
On Fri, 10 Jun 2016, Alexander Monakov wrote:

> On Wed, 1 Jun 2016, Richard Biener wrote:
> > > On Wed, 1 Jun 2016, Richard Biener wrote:
> > > > 2016-06-01  Richard Biener  <rguenther@suse.de>
> > > > 
> > > > 	* match.pd ((A & B) - (A & ~B) -> B - (A ^ B)): Add missing :c.
> > > > 	(relational patterns): Use :c to avoid pattern duplications.
> > > 
> > > Should the same treatment be applied to recently added IFN_MUL_OVERFLOW
> > > patterns (lines 2625-2643 in current match.pd)?
> > 
> > Ah, yeah - I missed those appearantly.
> 
> Here's a patch. Bootstrapped/regtested on x86_64, OK to apply?

Ok.

Thanks,
Richard.

> Thanks.
> Alexander
> 
> 	* match.pd (-1 / B < A): Use :c to avoid pattern duplication.
> 
> diff --git a/gcc/match.pd b/gcc/match.pd
> index fe71115..7d4beea 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -2626,22 +2626,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>         && types_match (TREE_TYPE (@0), TREE_TYPE (@1)))
>     (out (imagpart @2) { build_zero_cst (TREE_TYPE (@0)); }))))
>  
> -/* For unsigned operands, A > -1 / B checks whether A * B would overflow.
> +/* For unsigned operands, -1 / B < A checks whether A * B would overflow.
>     Simplify it to __builtin_mul_overflow (A, B, <unused>).  */
> -/* -1 / B < A */
>  (for cmp (lt ge)
>       out (ne eq)
>   (simplify
> -  (cmp (trunc_div:s integer_all_onesp @1) @0)
> -  (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && !VECTOR_TYPE_P (TREE_TYPE (@0)))
> -   (with { tree t = TREE_TYPE (@0), cpx = build_complex_type (t); }
> -    (out (imagpart (IFN_MUL_OVERFLOW:cpx @0 @1)) { build_zero_cst (t); })))))
> -
> -/* A > -1 / B */
> -(for cmp (gt le)
> -     out (ne eq)
> - (simplify
> -  (cmp @0 (trunc_div:s integer_all_onesp @1))
> +  (cmp:c (trunc_div:s integer_all_onesp @1) @0)
>    (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && !VECTOR_TYPE_P (TREE_TYPE (@0)))
>     (with { tree t = TREE_TYPE (@0), cpx = build_complex_type (t); }
>      (out (imagpart (IFN_MUL_OVERFLOW:cpx @0 @1)) { build_zero_cst (t); })))))
> 
>
diff mbox

Patch

diff --git a/gcc/match.pd b/gcc/match.pd
index fe71115..7d4beea 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2626,22 +2626,12 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        && types_match (TREE_TYPE (@0), TREE_TYPE (@1)))
    (out (imagpart @2) { build_zero_cst (TREE_TYPE (@0)); }))))
 
-/* For unsigned operands, A > -1 / B checks whether A * B would overflow.
+/* For unsigned operands, -1 / B < A checks whether A * B would overflow.
    Simplify it to __builtin_mul_overflow (A, B, <unused>).  */
-/* -1 / B < A */
 (for cmp (lt ge)
      out (ne eq)
  (simplify
-  (cmp (trunc_div:s integer_all_onesp @1) @0)
-  (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && !VECTOR_TYPE_P (TREE_TYPE (@0)))
-   (with { tree t = TREE_TYPE (@0), cpx = build_complex_type (t); }
-    (out (imagpart (IFN_MUL_OVERFLOW:cpx @0 @1)) { build_zero_cst (t); })))))
-
-/* A > -1 / B */
-(for cmp (gt le)
-     out (ne eq)
- (simplify
-  (cmp @0 (trunc_div:s integer_all_onesp @1))
+  (cmp:c (trunc_div:s integer_all_onesp @1) @0)
   (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && !VECTOR_TYPE_P (TREE_TYPE (@0)))
    (with { tree t = TREE_TYPE (@0), cpx = build_complex_type (t); }
     (out (imagpart (IFN_MUL_OVERFLOW:cpx @0 @1)) { build_zero_cst (t); })))))