re PR tree-optimization/90006 (gcc loops indefinitely around vect_get_constant_vector...
authorRichard Biener <rguenther@suse.de>
Mon, 8 Apr 2019 13:54:02 +0000 (13:54 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 8 Apr 2019 13:54:02 +0000 (13:54 +0000)
2019-04-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/90006
* tree-vect-data-refs.c (vect_get_smallest_scalar_type): Handle
calls like lrint.

* gcc.dg/vect/bb-slp-pr90006.c: New testcase.

From-SVN: r270210

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/bb-slp-pr90006.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c

index 51fc0bf9d5063d2b402b089aaeb3f8e60806b244..845f21e7f3bc1dc3bad096cbfb538d0974abe42f 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/90006
+       * tree-vect-data-refs.c (vect_get_smallest_scalar_type): Handle
+       calls like lrint.
+
 2019-04-08  Andrea Corallo  <andrea.corallo@arm.com>
 
        PR target/83033
index 9b7b08d0e0e3ea7b11d4b472f6f5c788b54b5740..038a431317c967ed53a8cf158b6550672bbc8fe5 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/90006
+       * gcc.dg/vect/bb-slp-pr90006.c: New testcase.
+
 2019-04-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/89865
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr90006.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr90006.c
new file mode 100644 (file)
index 0000000..104d3fb
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-math-errno" } */
+/* { dg-additional-options "-march=x86-64" { target x86_64-*-* i?86-*-* } } */
+
+long int lrint(double x);
+
+int a, b;
+union c {
+    int d;
+};
+
+int e()
+{
+  int f, g, h;
+  long i, j, k;
+  double l, m = b = lrint(0.3127);
+  a = b >> 16 >> 8 & 255;
+  ((union c *)e)->d = a;
+  k = m;
+  h = k >> 16 >> 8 & 255;
+  ((union c *)(e + 4))->d = h;
+  j = lrint(l);
+  g = j >> 16 >> 8 & 255;
+  ((union c *)(e + 8))->d = g;
+  i = lrint(0.292);
+  f = i >> 16 >> 8 & 255;
+  ((union c *)(e + 12))->d = f;
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "basic block vectorized" "slp2" { target { { x86_64-*-* i?86-*-* } && ilp32 } } } } */
index 1380088af6a4c7ab0ef66d39276caef6682df5e9..8f185c99dad58defb584cf9351157f2441e178b8 100644 (file)
@@ -141,6 +141,15 @@ vect_get_smallest_scalar_type (stmt_vec_info stmt_info,
     {
       tree rhs_type = TREE_TYPE (gimple_assign_rhs1 (assign));
 
+      rhs = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (rhs_type));
+      if (rhs < lhs)
+        scalar_type = rhs_type;
+    }
+  else if (is_gimple_call (stmt_info->stmt)
+          && gimple_call_num_args (stmt_info->stmt) > 0)
+    {
+      tree rhs_type = TREE_TYPE (gimple_call_arg (stmt_info->stmt, 0));
+
       rhs = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (rhs_type));
       if (rhs < lhs)
         scalar_type = rhs_type;