]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Thu, 7 Jun 2018 10:10:00 +0000 (10:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 7 Jun 2018 10:10:00 +0000 (10:10 +0000)
2018-06-07  Richard Biener  <rguenther@suse.de>

Backport from mainline
2018-05-04  Richard Biener  <rguenther@suse.de>

PR middle-end/85588
* fold-const.c (negate_expr_p): Restrict negation of operand
zero of a division to when we know that can happen without
overflow.
(fold_negate_expr_1): Likewise.

* gcc.dg/torture/pr85588.c: New testcase.
* gcc.dg/torture/pr57656.c: Use dg-additional-options.

2018-05-02  Richard Biener  <rguenther@suse.de>

PR middle-end/85567
* gimplify.c (gimplify_save_expr): When in SSA form allow
SAVE_EXPRs to compute to SSA vars.

* gcc.dg/torture/pr85567.c: New testcase.

2018-05-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/85597
* tree-vect-stmts.c (vectorizable_operation): For ternary SLP
do not use split vect_get_vec_defs call but call vect_get_slp_defs
directly.

* gcc.dg/vect/pr85597.c: New testcase.

From-SVN: r261269

gcc/ChangeLog
gcc/fold-const.c
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr57656.c
gcc/testsuite/gcc.dg/torture/pr85567.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr85588.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr85597.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 534bc9b91afaa0734c0b30c73f3e9efebe8b5d1d..2f52cbcae0d7f7f45c3ef0f885b26e8ef5dbd3f0 100644 (file)
@@ -1,3 +1,27 @@
+2018-06-07  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2018-05-04  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/85588
+       * fold-const.c (negate_expr_p): Restrict negation of operand
+       zero of a division to when we know that can happen without
+       overflow.
+       (fold_negate_expr_1): Likewise.
+
+       2018-05-02  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/85567
+       * gimplify.c (gimplify_save_expr): When in SSA form allow
+       SAVE_EXPRs to compute to SSA vars.
+
+       2018-05-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/85597
+       * tree-vect-stmts.c (vectorizable_operation): For ternary SLP
+       do not use split vect_get_vec_defs call but call vect_get_slp_defs
+       directly.
+
 2018-06-05  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        Backport from mainline
index 0781f4212b7e26ca65963bd8f7838a05ad4a1a7b..8e1b062376351fe2150175b58929de74927e04c3 100644 (file)
@@ -473,12 +473,15 @@ negate_expr_p (tree t)
     case EXACT_DIV_EXPR:
       if (TYPE_UNSIGNED (type))
        break;
-      if (negate_expr_p (TREE_OPERAND (t, 0)))
+      /* In general we can't negate A in A / B, because if A is INT_MIN and
+         B is not 1 we change the sign of the result.  */
+      if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST
+         && negate_expr_p (TREE_OPERAND (t, 0)))
        return true;
       /* In general we can't negate B in A / B, because if A is INT_MIN and
         B is 1, we may turn this into INT_MIN / -1 which is undefined
         and actually traps on some architectures.  */
-      if (! INTEGRAL_TYPE_P (TREE_TYPE (t))
+      if (! ANY_INTEGRAL_TYPE_P (TREE_TYPE (t))
          || TYPE_OVERFLOW_WRAPS (TREE_TYPE (t))
          || (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST
              && ! integer_onep (TREE_OPERAND (t, 1))))
@@ -652,14 +655,17 @@ fold_negate_expr_1 (location_t loc, tree t)
     case EXACT_DIV_EXPR:
       if (TYPE_UNSIGNED (type))
        break;
-      if (negate_expr_p (TREE_OPERAND (t, 0)))
+      /* In general we can't negate A in A / B, because if A is INT_MIN and
+        B is not 1 we change the sign of the result.  */
+      if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST
+         && negate_expr_p (TREE_OPERAND (t, 0)))
        return fold_build2_loc (loc, TREE_CODE (t), type,
                                negate_expr (TREE_OPERAND (t, 0)),
                                TREE_OPERAND (t, 1));
       /* In general we can't negate B in A / B, because if A is INT_MIN and
         B is 1, we may turn this into INT_MIN / -1 which is undefined
         and actually traps on some architectures.  */
-      if ((! INTEGRAL_TYPE_P (TREE_TYPE (t))
+      if ((! ANY_INTEGRAL_TYPE_P (TREE_TYPE (t))
           || TYPE_OVERFLOW_WRAPS (TREE_TYPE (t))
           || (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST
               && ! integer_onep (TREE_OPERAND (t, 1))))
index 15fc7c9ae8f64d81cff1883f86776b1a7aac3404..5535604d8373fe53700b7a4ba9f3ee741d513fe3 100644 (file)
@@ -5773,8 +5773,11 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
        }
       else
        /* The temporary may not be an SSA name as later abnormal and EH
-          control flow may invalidate use/def domination.  */
-       val = get_initialized_tmp_var (val, pre_p, post_p, false);
+          control flow may invalidate use/def domination.  When in SSA
+          form then assume there are no such issues and SAVE_EXPRs only
+          appear via GENERIC foldings.  */
+       val = get_initialized_tmp_var (val, pre_p, post_p,
+                                      gimple_in_ssa_p (cfun));
 
       TREE_OPERAND (*expr_p, 0) = val;
       SAVE_EXPR_RESOLVED_P (*expr_p) = 1;
index 7a8d45f238183cf04c9443aecf72ec90b58320b8..df89b1f06c902c3ef851627bd14f62366b3dd1b0 100644 (file)
@@ -1,3 +1,22 @@
+2018-06-07  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2018-05-04  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/85588
+       * gcc.dg/torture/pr85588.c: New testcase.
+       * gcc.dg/torture/pr57656.c: Use dg-additional-options.
+
+       2018-05-02  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/85567
+       * gcc.dg/torture/pr85567.c: New testcase.
+
+       2018-05-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/85597
+       * gcc.dg/vect/pr85597.c: New testcase.
+
 2018-06-05  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        Backport from mainline
index 4f3645e4693ea2895bdb1e50eb42448f8d579cc4..02490140105984cc4cf424912fbebbd2e77ddcb5 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-fstrict-overflow" } */
+/* { dg-additional-options "-fstrict-overflow" } */
 
 int main (void)
 {
diff --git a/gcc/testsuite/gcc.dg/torture/pr85567.c b/gcc/testsuite/gcc.dg/torture/pr85567.c
new file mode 100644 (file)
index 0000000..f20c69f
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+extern void sincos(double x, double *sinx, double *cosx);
+
+void apply(void (*f)(double, double *, double *),
+          double x, double *sinx, double *cosx)
+{
+  f(x, sinx, cosx);
+  return;
+}
+
+void apply_sincos(double x, double *sinx, double *cosx)
+{
+  apply(sincos, x, sinx, cosx);
+  return;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr85588.c b/gcc/testsuite/gcc.dg/torture/pr85588.c
new file mode 100644 (file)
index 0000000..5d95c96
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fwrapv" } */
+
+#include "pr57656.c"
diff --git a/gcc/testsuite/gcc.dg/vect/pr85597.c b/gcc/testsuite/gcc.dg/vect/pr85597.c
new file mode 100644 (file)
index 0000000..cf615f9
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-mfma" { target { x86_64-*-* i?86-*-* } } } */
+
+extern double fma (double, double, double);
+
+static inline void
+bar (int i, double *D, double *S)
+{
+  while (i-- > 0)
+    {
+      D[0] = fma (1, S[0], D[0]);
+      D[1] = fma (1, S[1], D[1]);
+      D[2] = fma (1, S[2], D[2]);
+      D[3] = fma (1, S[3], D[3]);
+      D += 4;
+      S += 4;
+    }
+}
+
+void
+foo (double *d, double *s)
+{
+  bar (10, d, s);
+}
+
index b5601727c53a423243bcc5425d4d6231bc499432..04237dbb9fe03bf8a6fcdb77a612bd26c9db3911 100644 (file)
@@ -5479,15 +5479,34 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
       /* Handle uses.  */
       if (j == 0)
        {
-         if (op_type == binary_op || op_type == ternary_op)
+         if (op_type == binary_op)
            vect_get_vec_defs (op0, op1, stmt, &vec_oprnds0, &vec_oprnds1,
                               slp_node, -1);
+         else if (op_type == ternary_op)
+           {
+             if (slp_node)
+               {
+                 auto_vec<tree> ops(3);
+                 ops.quick_push (op0);
+                 ops.quick_push (op1);
+                 ops.quick_push (op2);
+                 auto_vec<vec<tree> > vec_defs(3);
+                 vect_get_slp_defs (ops, slp_node, &vec_defs, -1);
+                 vec_oprnds0 = vec_defs[0];
+                 vec_oprnds1 = vec_defs[1];
+                 vec_oprnds2 = vec_defs[2];
+               }
+             else
+               { 
+                 vect_get_vec_defs (op0, op1, stmt, &vec_oprnds0, &vec_oprnds1,
+                                    NULL, -1);
+                 vect_get_vec_defs (op2, NULL_TREE, stmt, &vec_oprnds2, NULL,
+                                    NULL, -1);
+               }
+           }
          else
            vect_get_vec_defs (op0, NULL_TREE, stmt, &vec_oprnds0, NULL,
                               slp_node, -1);
-         if (op_type == ternary_op)
-           vect_get_vec_defs (op2, NULL_TREE, stmt, &vec_oprnds2, NULL,
-                              slp_node, -1);
        }
       else
        {