From: Kugan Vivekanandarajah Date: Mon, 29 Oct 2018 00:03:20 +0000 (+0000) Subject: gimplefe-30.c: New test. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=64f7ea7c546ff900eb7647b1726082007a7cd3a2;p=gcc.git gimplefe-30.c: New test. gcc/testsuite/ChangeLog: 2018-10-28 Kugan Vivekanandarajah * gcc.dg/gimplefe-30.c: New test. * gcc.dg/gimplefe-31.c: New test. * gcc.dg/gimplefe-32.c: New test. * gcc.dg/gimplefe-33.c: New test. gcc/ChangeLog: 2018-10-28 Kugan Vivekanandarajah * doc/generic.texi (ABSU_EXPR): Document. * match.pd (absu(x)*absu(x) -> x*x): Handle. (absu(absu(X)) -> absu(X)): Likewise. (absu(-X) -> absu(X)): Likewise. (absu(X) where X is nonnegative -> X): Likewise. From-SVN: r265578 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4ac333abc98..e1b641fc005 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-10-28 Kugan Vivekanandarajah + + * doc/generic.texi (ABSU_EXPR): Document. + * match.pd (absu(x)*absu(x) -> x*x): Handle. + (absu(absu(X)) -> absu(X)): Likewise. + (absu(-X) -> absu(X)): Likewise. + (absu(X) where X is nonnegative -> X): Likewise. + 2018-10-28 Iain Buclaw * Makefile.in (tm_d_file_list, tm_d_include_list): New variables. diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index cf4bcf5a221..5d0a541451a 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -1274,6 +1274,7 @@ the byte offset of the field, but should not be used directly; call @subsection Unary and Binary Expressions @tindex NEGATE_EXPR @tindex ABS_EXPR +@tindex ABSU_EXPR @tindex BIT_NOT_EXPR @tindex TRUTH_NOT_EXPR @tindex PREDECREMENT_EXPR @@ -1371,6 +1372,11 @@ or complex abs of a complex value, use the @code{BUILT_IN_CABS}, to implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl} built-in functions. +@item ABSU_EXPR +These nodes represent the absolute value of the single operand in +equivalent unsigned type such that @code{ABSU_EXPR} of TYPE_MIN is +well defined. + @item BIT_NOT_EXPR These nodes represent bitwise complement, and will always have integral type. The only operand is the value to be complemented. diff --git a/gcc/match.pd b/gcc/match.pd index 8796a406f82..d07ceb7d087 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -590,6 +590,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (mult (abs@1 @0) @1) (mult @0 @0)) +/* Convert absu(x)*absu(x) -> x*x. */ +(simplify + (mult (absu@1 @0) @1) + (mult (convert@2 @0) @2)) + /* cos(copysign(x, y)) -> cos(x). Similarly for cosh. */ (for coss (COS COSH) copysigns (COPYSIGN) @@ -1121,16 +1126,35 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && tree_nop_conversion_p (type, TREE_TYPE (@2))) (bit_xor (convert @1) (convert @2)))) +/* Convert abs (abs (X)) into abs (X). + also absu (absu (X)) into absu (X). */ (simplify (abs (abs@1 @0)) @1) + +(simplify + (absu (convert@2 (absu@1 @0))) + (if (tree_nop_conversion_p (TREE_TYPE (@2), TREE_TYPE (@1))) + @1)) + +/* Convert abs[u] (-X) -> abs[u] (X). */ (simplify (abs (negate @0)) (abs @0)) + +(simplify + (absu (negate @0)) + (absu @0)) + +/* Convert abs[u] (X) where X is nonnegative -> (X). */ (simplify (abs tree_expr_nonnegative_p@0) @0) +(simplify + (absu tree_expr_nonnegative_p@0) + (convert @0)) + /* A few cases of fold-const.c negate_expr_p predicate. */ (match negate_expr_p INTEGER_CST diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e49edfb2328..40ea5a7b436 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-10-28 Kugan Vivekanandarajah + + * gcc.dg/gimplefe-30.c: New test. + * gcc.dg/gimplefe-31.c: New test. + * gcc.dg/gimplefe-32.c: New test. + * gcc.dg/gimplefe-33.c: New test. + 2018-10-28 Iain Buclaw * gcc.misc-tests/help.exp: Add D to option descriptions check. diff --git a/gcc/testsuite/gcc.dg/gimplefe-30.c b/gcc/testsuite/gcc.dg/gimplefe-30.c new file mode 100644 index 00000000000..6c251061604 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-30.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + +unsigned int __GIMPLE() f(int a) +{ + unsigned int t0; + unsigned int t1; + unsigned int t2; + t0 = __ABSU a; + t1 = __ABSU a; + t2 = t0 * t1; + return t2; +} + + +/* { dg-final { scan-tree-dump-times "ABSU" 0 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/gimplefe-31.c b/gcc/testsuite/gcc.dg/gimplefe-31.c new file mode 100644 index 00000000000..a97d0dd65e3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-31.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + + +unsigned int __GIMPLE() f(int a) +{ + unsigned int t0; + int t1; + unsigned int t2; + t0 = __ABSU a; + t1 = (int) t0; + t2 = __ABSU t1; + return t2; +} + +/* { dg-final { scan-tree-dump-times "ABSU" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/gimplefe-32.c b/gcc/testsuite/gcc.dg/gimplefe-32.c new file mode 100644 index 00000000000..9b3963cdde2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-32.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + +unsigned int __GIMPLE() f(int a) +{ + int t0; + unsigned int t1; + t0 = -a; + t1 = __ABSU a; + return t1; +} + + +/* { dg-final { scan-tree-dump-times "= -" 0 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/gimplefe-33.c b/gcc/testsuite/gcc.dg/gimplefe-33.c new file mode 100644 index 00000000000..4e4982247cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-33.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + +int __GIMPLE() f(int c) +{ + int D; + int _1; + unsigned int _2; + _1 = __ABS c; + _2 = __ABSU _1; + D = (int) _2; + return D; +} + + +/* { dg-final { scan-tree-dump-times "ABSU" 0 "optimized" } } */