re PR tree-optimization/70509 (wrong code with extract from a v64qi)
authorZdenek Sojka <zsojka@seznam.cz>
Tue, 5 Apr 2016 16:58:50 +0000 (18:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Apr 2016 16:58:50 +0000 (18:58 +0200)
PR tree-optimization/70509
* tree-ssa-forwprop.c (simplify_bitfield_ref): Use bitsize_int instead
of the vector base type for index.

* gcc.target/i386/avx512bw-pr70509.c: New test.

From-SVN: r234754

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx512bw-pr70509.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index 711f6ed..c2a26d5 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-05  Zdenek Sojka  <zsojka@seznam.cz>
+
+       PR tree-optimization/70509
+       * tree-ssa-forwprop.c (simplify_bitfield_ref): Use bitsize_int instead
+       of the vector base type for index.
+
 2016-04-05  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/70510
index 957823d..92ea4a5 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-05  Zdenek Sojka  <zsojka@seznam.cz>
+
+       PR tree-optimization/70509
+       * gcc.target/i386/avx512bw-pr70509.c: New test.
+
 2016-04-05  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/70452
diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr70509.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr70509.c
new file mode 100644 (file)
index 0000000..d7bd659
--- /dev/null
@@ -0,0 +1,26 @@
+/* PR tree-optimization/70509 */
+/* { dg-do run } */
+/* { dg-options "-O1 -mavx512bw" } */
+/* { dg-require-effective-target avx512bw } */
+
+#define AVX512BW
+#include "avx512f-helper.h"
+
+typedef char V __attribute__ ((vector_size (64)));
+
+int __attribute__ ((noinline, noclone))
+foo (V u, V v)
+{
+  u /= v[0x20];
+  return u[0];
+}
+
+void
+TEST (void)
+{
+  int x = foo ((V) { 9 }, (V) { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+                               2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+                               3 });
+  if (x != 3)
+    abort ();
+}
index f64ee0a..c40f9e2 100644 (file)
@@ -1773,7 +1773,7 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
 
   if (code == VEC_PERM_EXPR)
     {
-      tree p, m, index, tem;
+      tree p, m, tem;
       unsigned nelts;
       m = gimple_assign_rhs3 (def_stmt);
       if (TREE_CODE (m) != VECTOR_CST)
@@ -1790,9 +1790,8 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
          p = gimple_assign_rhs2 (def_stmt);
          idx -= nelts;
        }
-      index = build_int_cst (TREE_TYPE (TREE_TYPE (m)), idx * size);
       tem = build3 (BIT_FIELD_REF, TREE_TYPE (op),
-                   unshare_expr (p), op1, index);
+                   unshare_expr (p), op1, bitsize_int (idx * size));
       gimple_assign_set_rhs1 (stmt, tem);
       fold_stmt (gsi);
       update_stmt (gsi_stmt (*gsi));