]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/54713 (error: non-trivial conversion at assignment in gcc...
authorJakub Jelinek <jakub@redhat.com>
Fri, 28 Sep 2012 12:18:57 +0000 (14:18 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 28 Sep 2012 12:18:57 +0000 (14:18 +0200)
PR tree-optimization/54713
* fold-const.c (vec_cst_ctor_to_array): Give up if vector CONSTRUCTOR
has vector elements.
(fold_ternary_loc) <case BIT_FIELD_REF>: Likewise.
* tree-vect-generic.c (vector_element): Don't rely on CONSTRUCTOR elts
indexes.  Use BIT_FIELD_REF if CONSTRUCTOR has vector elements.
(lower_vec_perm): Use NULL_TREE CONSTRUCTOR indexes.

* gcc.c-torture/compile/pr54713-1.c: New test.
* gcc.c-torture/compile/pr54713-2.c: New test.
* gcc.c-torture/compile/pr54713-3.c: New test.

From-SVN: r191826

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr54713-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr54713-2.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr54713-3.c [new file with mode: 0644]
gcc/tree-vect-generic.c

index 796f772633dd04a9274488c6ff4a9bd7a8400588..d45df05746f33523e34663957be6c07cbfa6f222 100644 (file)
@@ -1,3 +1,13 @@
+2012-09-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54713
+       * fold-const.c (vec_cst_ctor_to_array): Give up if vector CONSTRUCTOR
+       has vector elements.
+       (fold_ternary_loc) <case BIT_FIELD_REF>: Likewise.
+       * tree-vect-generic.c (vector_element): Don't rely on CONSTRUCTOR elts
+       indexes.  Use BIT_FIELD_REF if CONSTRUCTOR has vector elements.
+       (lower_vec_perm): Use NULL_TREE CONSTRUCTOR indexes.
+
 2012-09-28  Georg-Johann Lay  <avr@gjlay.de>
 
        * config/avr/avr.md (adjust_len): Add lpm.
index ce522357ee29b0ae104e549cff45a5993f2b688d..fd0075c4971cc8c85633ae183e5fcac1ca259d67 100644 (file)
@@ -9559,7 +9559,7 @@ vec_cst_ctor_to_array (tree arg, tree *elts)
       constructor_elt *elt;
 
       FOR_EACH_VEC_ELT (constructor_elt, CONSTRUCTOR_ELTS (arg), i, elt)
-       if (i >= nelts)
+       if (i >= nelts || TREE_CODE (TREE_TYPE (elt->value)) == VECTOR_TYPE)
          return false;
        else
          elts[i] = elt->value;
@@ -14030,22 +14030,35 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
                      unsigned i;
                      if (CONSTRUCTOR_NELTS (arg0) == 0)
                        return build_constructor (type, NULL);
-                     vals = VEC_alloc (constructor_elt, gc, n);
-                     for (i = 0; i < n && idx + i < CONSTRUCTOR_NELTS (arg0);
-                          ++i)
-                       CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE,
-                                               CONSTRUCTOR_ELT
-                                                 (arg0, idx + i)->value);
-                     return build_constructor (type, vals);
+                     if (TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (arg0,
+                                                                0)->value))
+                         != VECTOR_TYPE)
+                       {
+                         vals = VEC_alloc (constructor_elt, gc, n);
+                         for (i = 0;
+                              i < n && idx + i < CONSTRUCTOR_NELTS (arg0);
+                              ++i)
+                           CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE,
+                                                   CONSTRUCTOR_ELT
+                                                     (arg0, idx + i)->value);
+                         return build_constructor (type, vals);
+                       }
                    }
                }
              else if (n == 1)
                {
                  if (TREE_CODE (arg0) == VECTOR_CST)
                    return VECTOR_CST_ELT (arg0, idx);
-                 else if (idx < CONSTRUCTOR_NELTS (arg0))
-                   return CONSTRUCTOR_ELT (arg0, idx)->value;
-                 return build_zero_cst (type);
+                 else if (CONSTRUCTOR_NELTS (arg0) == 0)
+                   return build_zero_cst (type);
+                 else if (TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (arg0,
+                                                                 0)->value))
+                          != VECTOR_TYPE)
+                   {
+                     if (idx < CONSTRUCTOR_NELTS (arg0))
+                       return CONSTRUCTOR_ELT (arg0, idx)->value;
+                     return build_zero_cst (type);
+                   }
                }
            }
        }
index ca52687a705c60a1788252165e9855b054eb39b2..2ea0e80d7a726b0666f1efe8bbc9be009be38fdd 100644 (file)
@@ -1,3 +1,10 @@
+2012-09-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54713
+       * gcc.c-torture/compile/pr54713-1.c: New test.
+       * gcc.c-torture/compile/pr54713-2.c: New test.
+       * gcc.c-torture/compile/pr54713-3.c: New test.
+
 2012-09-27  Janis Johnson  <janisjo@codesourcery.com>
 
        * gcc.target/arm/unsigned-extend-1.c: Omit -march option.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c b/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c
new file mode 100644 (file)
index 0000000..f042ea2
--- /dev/null
@@ -0,0 +1,70 @@
+/* PR tree-optimization/54713 */
+
+#ifndef N
+#define N 8
+#define ONE 1, 1, 1, 1, 1, 1, 1, 1
+#define ONEU 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U
+#endif
+
+typedef int V __attribute__((vector_size (N * sizeof (int))));
+typedef unsigned int W __attribute__((vector_size (N * sizeof (int))));
+
+void
+f1 (V *p)
+{
+  *p = (*p & ((V) { ONE })) ^ ((V) { ONE});
+}
+
+void
+f2 (V *p)
+{
+  *p = (*p ^ ((V) { ONE })) & ((V) { ONE});
+}
+
+void
+f3 (V *p)
+{
+  *p = (~*p) & ((V) { ONE });
+}
+
+void
+f4 (V *p, V *q)
+{
+  *p = (*p ^ *q) == *q;
+}
+
+void
+f5 (V *p, V *q)
+{
+  *p = (*p ^ *q) == *p;
+}
+
+void
+f6 (V *p, V *q, V *r)
+{
+  *p = (*p & *r) == (*q & *r);
+}
+
+void
+f7 (V *p, V *q, V *r)
+{
+  *p = (*p & *r) == (*r & *q);
+}
+
+void
+f8 (V *p, V *q, V *r)
+{
+  *p = (*r & *p) == (*q & *r);
+}
+
+void
+f9 (V *p, V *q, V *r)
+{
+  *p = (*r & *p) == (*r & *q);
+}
+
+void
+f10 (W *p, W *q)
+{
+  *p = *p < (((const W) { ONEU }) << *q);
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c b/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c
new file mode 100644 (file)
index 0000000..c391037
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR tree-optimization/54713 */
+
+#define N 16
+#define ONE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#define ONEU 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U
+
+#include "pr54713-1.c"
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c b/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c
new file mode 100644 (file)
index 0000000..6164a5e
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR tree-optimization/54713 */
+
+#define N 32
+#define ONE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+           1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1    
+#define ONEU 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, \
+            1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U
+
+#include "pr54713-1.c"
index 85fb3a29bca07beabcf227bb454f57cebdbb2101..d950d814870f05dd592ff54e17def7c4bd2c7403 100644 (file)
@@ -1050,14 +1050,13 @@ vector_element (gimple_stmt_iterator *gsi, tree vect, tree idx, tree *ptmpvec)
 
       if (TREE_CODE (vect) == VECTOR_CST)
        return VECTOR_CST_ELT (vect, index);
-      else if (TREE_CODE (vect) == CONSTRUCTOR)
+      else if (TREE_CODE (vect) == CONSTRUCTOR
+              && (CONSTRUCTOR_NELTS (vect) == 0
+                  || TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (vect, 0)->value))
+                     != VECTOR_TYPE))
         {
-          unsigned i;
-          tree elt_i, elt_v;
-
-         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (vect), i, elt_i, elt_v)
-            if (operand_equal_p (elt_i, idx, 0))
-              return elt_v;
+         if (index < CONSTRUCTOR_NELTS (vect))
+           return CONSTRUCTOR_ELT (vect, index)->value;
           return build_zero_cst (vect_elt_type);
         }
       else
@@ -1215,7 +1214,7 @@ lower_vec_perm (gimple_stmt_iterator *gsi)
            t = v0_val;
         }
 
-      CONSTRUCTOR_APPEND_ELT (v, si, t);
+      CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, t);
     }
 
   constr = build_constructor (vect_type, v);