]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimplefe-30.c: New test.
authorKugan Vivekanandarajah <kuganv@linaro.org>
Mon, 29 Oct 2018 00:03:20 +0000 (00:03 +0000)
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>
Mon, 29 Oct 2018 00:03:20 +0000 (00:03 +0000)
gcc/testsuite/ChangeLog:

2018-10-28  Kugan Vivekanandarajah  <kuganv@linaro.org>

* 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  <kuganv@linaro.org>

* 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

gcc/ChangeLog
gcc/doc/generic.texi
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gimplefe-30.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gimplefe-31.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gimplefe-32.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gimplefe-33.c [new file with mode: 0644]

index 4ac333abc981753cda0da494168b4ba13140258d..e1b641fc005a5752915660cb5ba62d4993f1e58f 100644 (file)
@@ -1,3 +1,11 @@
+2018-10-28  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       * 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  <ibuclaw@gdcproject.org>
 
        * Makefile.in (tm_d_file_list, tm_d_include_list): New variables.
index cf4bcf5a2218988cfd766eea8d8aaaaec3a432d7..5d0a541451a38795d61c23df6219e4534f24318a 100644 (file)
@@ -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.
index 8796a406f82031f90a4394ff54d90b9568d4863c..d07ceb7d087b8b5c5a7d7362ad9d8f71ac90dc08 100644 (file)
@@ -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
index e49edfb23288b45bef1012cf40ba6ff36cb07b3f..40ea5a7b436a5fa4861cea359582da1689cfefa1 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-28  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       * 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  <ibuclaw@gdcproject.org>
 
        * 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 (file)
index 0000000..6c25106
--- /dev/null
@@ -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 (file)
index 0000000..a97d0dd
--- /dev/null
@@ -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 (file)
index 0000000..9b3963c
--- /dev/null
@@ -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 (file)
index 0000000..4e49822
--- /dev/null
@@ -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" } } */