re PR middle-end/30784 (ICE on loop vectorization (-O1 -march=athlon-xp -ftree-vector...
authorDorit Nuzman <dorit@il.ibm.com>
Sun, 25 Mar 2007 11:08:29 +0000 (11:08 +0000)
committerDorit Nuzman <dorit@gcc.gnu.org>
Sun, 25 Mar 2007 11:08:29 +0000 (11:08 +0000)
        PR tree-optimization/30784
        * fold-const.c (fold_ternary): Handle CONSTRUCTOR in case
        BIT_FIELD_REF.

From-SVN: r123197

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr30784.c [new file with mode: 0644]

index a8902bf5d7731691e93891feef33d5ab8768793b..fa1e4b3ad2128680971e3728e101b9c24b4d3df2 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-25  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/30784
+       * fold-const.c (fold_ternary): Handle CONSTRUCTOR in case
+       BIT_FIELD_REF.
+
 2007-03-25  Revital Eres  <eres@il.ibm.com>
 
         * tree-if-conv.c (if_convertible_gimple_modify_stmt_p):
index e4efda0f9410f9d6c5eceaccb177fa1b42d7c506..66bcbbcd3620bc4d01013c63d88fef277f6b444c 100644 (file)
@@ -12470,7 +12470,8 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
       gcc_unreachable ();
 
     case BIT_FIELD_REF:
-      if (TREE_CODE (arg0) == VECTOR_CST
+      if ((TREE_CODE (arg0) == VECTOR_CST
+          || (TREE_CODE (arg0) == CONSTRUCTOR && TREE_CONSTANT (arg0)))
          && type == TREE_TYPE (TREE_TYPE (arg0))
          && host_integerp (arg1, 1)
          && host_integerp (op2, 1))
@@ -12484,7 +12485,18 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
              && (idx = idx / width)
                 < TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)))
            {
-             tree elements = TREE_VECTOR_CST_ELTS (arg0);
+             tree elements = NULL_TREE;
+
+             if (TREE_CODE (arg0) == VECTOR_CST)
+               elements = TREE_VECTOR_CST_ELTS (arg0);
+             else
+               {
+                 unsigned HOST_WIDE_INT idx;
+                 tree value;
+
+                 FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (arg0), idx, value)
+                   elements = tree_cons (NULL_TREE, value, elements);
+               }
              while (idx-- > 0 && elements)
                elements = TREE_CHAIN (elements);
              if (elements)
index 8bd087add9240a5142d633c2f80e24a5946c80cd..d8b23d858002e539d3ac993a704ced1901e61cfd 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-25  Dorit Nuzman  <dorit@il.ibm.com>
+
+       PR tree-optimization/30784
+        * gcc.dg/vect/pr30784.c: New test.
+
 2007-03-25  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/30877
diff --git a/gcc/testsuite/gcc.dg/vect/pr30784.c b/gcc/testsuite/gcc.dg/vect/pr30784.c
new file mode 100644 (file)
index 0000000..3df9afe
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+long stack_vars_sorted[32];
+
+int
+main1 (long n)
+{
+  long si;
+
+  for (si = 0; si < n; ++si)
+    stack_vars_sorted[si] = si;
+}
+
+int main ()
+{
+  long si;
+
+  check_vect ();
+  main1 (32);
+
+  for (si = 0; si < 32; ++si)
+    if (stack_vars_sorted[si] != si)
+      abort ();
+
+  return 0;
+}
+/* { dg-final { cleanup-tree-dump "vect" } } */