re PR tree-optimization/49483 (unable to vectorize code equivalent to "scalbnf")
authorRichard Guenther <rguenther@suse.de>
Tue, 21 Jun 2011 11:02:38 +0000 (11:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 21 Jun 2011 11:02:38 +0000 (11:02 +0000)
2011-06-21  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/49483
* tree-vect-stmts.c (vectorizable_assignment): Also handle
VIEW_CONVERT_EXPR conversions.

* gcc.dg/vect/vect-120.c: New testcase.

From-SVN: r175252

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

index 60e53955f0a0b39aeeffa8df38736b398422bb9c..4ec260347d879aecfe2ad919423f4aa9d2c65d56 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/49483
+       * tree-vect-stmts.c (vectorizable_assignment): Also handle
+       VIEW_CONVERT_EXPR conversions.
+
 2011-06-21  Joseph Myers  <joseph@codesourcery.com>
 
        * config/avr/avr-mcus.def, config/avr/genopt.sh: New files.
index 20fc4a412b2e6d9cc28b0d3be2510ffa44d15e63..9dec802661d537382c2fffcaca24ebc4128238fe 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/49483
+       * gcc.dg/vect/vect-120.c: New testcase.
+
 2011-06-21  Ira Rosen  <ira.rosen@linaro.org>
 
        PR testsuite/49443
diff --git a/gcc/testsuite/gcc.dg/vect/vect-120.c b/gcc/testsuite/gcc.dg/vect/vect-120.c
new file mode 100644 (file)
index 0000000..b9a2f50
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+/* { dg-require-effective-target vect_shift } */
+
+static inline float
+i2f(int x)
+{
+  union { float f; int i; } tmp;
+  tmp.i=x;
+  return tmp.f;
+}
+static inline float
+vect_ldexpf(float x, int n)
+{
+  n = (n+0x7f)<<23;
+  return x * i2f(n);
+}
+
+float __attribute__ ((aligned(16))) a[1024];
+float __attribute__ ((aligned(16))) b[1024];
+float __attribute__ ((aligned(16))) c[1024];
+
+void
+tV()
+{
+  int i;
+  for (i=0; i!=1024; ++i)
+    {
+      float z = a[i];
+      int n = b[i];
+      c[i] = vect_ldexpf(z,n);
+    }
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 6a5ba22d42a4abc2c2f9a0fe17d5638d45d89fec..f9b963910816fb08fdd9dbcae163bd6f5085df33 100644 (file)
@@ -2089,6 +2089,9 @@ vectorizable_assignment (gimple stmt, gimple_stmt_iterator *gsi,
   else
     return false;
 
+  if (code == VIEW_CONVERT_EXPR)
+    op = TREE_OPERAND (op, 0);
+
   if (!vect_is_simple_use_1 (op, loop_vinfo, bb_vinfo,
                             &def_stmt, &def, &dt[0], &vectype_in))
     {
@@ -2099,7 +2102,8 @@ vectorizable_assignment (gimple stmt, gimple_stmt_iterator *gsi,
 
   /* We can handle NOP_EXPR conversions that do not change the number
      of elements or the vector size.  */
-  if (CONVERT_EXPR_CODE_P (code)
+  if ((CONVERT_EXPR_CODE_P (code)
+       || code == VIEW_CONVERT_EXPR)
       && (!vectype_in
          || TYPE_VECTOR_SUBPARTS (vectype_in) != nunits
          || (GET_MODE_SIZE (TYPE_MODE (vectype))
@@ -2134,7 +2138,8 @@ vectorizable_assignment (gimple stmt, gimple_stmt_iterator *gsi,
       /* Arguments are ready. create the new vector stmt.  */
       FOR_EACH_VEC_ELT (tree, vec_oprnds, i, vop)
        {
-        if (CONVERT_EXPR_CODE_P (code))
+        if (CONVERT_EXPR_CODE_P (code)
+            || code == VIEW_CONVERT_EXPR)
           vop = build1 (VIEW_CONVERT_EXPR, vectype, vop);
          new_stmt = gimple_build_assign (vec_dest, vop);
          new_temp = make_ssa_name (vec_dest, new_stmt);