re PR tree-optimization/85597 (internal compiler error: in compute_live_loop_exits...
authorRichard Biener <rguenther@suse.de>
Wed, 2 May 2018 14:19:51 +0000 (14:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 2 May 2018 14:19:51 +0000 (14:19 +0000)
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: r259840

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr85597.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 1c50825790b831b7e473333aacdf652c7cb470ab..1c2a8283ed62123eb3d4eaba82db6b2a17446a54 100644 (file)
@@ -1,3 +1,10 @@
+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-05-02  Tom de Vries  <tom@codesourcery.com>
 
        PR testsuite/85106
index e6ee793567a164ce35087de9a40e2d030673df4b..ecd2de3bc27421833a99ec2a3ab9bbf376e02f0e 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/85597
+       * gcc.dg/vect/pr85597.c: New testcase.
+
 2018-05-02  Tom de Vries  <tom@codesourcery.com>
 
        PR testsuite/85106
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 3e73118d99119c10e3a60d9b366fba240567f96e..7ebc426bd3ecbec9c95270810c70e0ecaff4c999 100644 (file)
@@ -5923,15 +5923,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);
+         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);
+                 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);
+                 vect_get_vec_defs (op2, NULL_TREE, stmt, &vec_oprnds2, NULL,
+                                    NULL);
+               }
+           }
          else
            vect_get_vec_defs (op0, NULL_TREE, stmt, &vec_oprnds0, NULL,
                               slp_node);
-         if (op_type == ternary_op)
-           vect_get_vec_defs (op2, NULL_TREE, stmt, &vec_oprnds2, NULL,
-                              slp_node);
        }
       else
        {