re PR tree-optimization/40496 (ICE in verify_stmts with -fprefetch-loop-arrays)
authorRichard Guenther <rguenther@suse.de>
Fri, 10 Jul 2009 11:45:40 +0000 (11:45 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 10 Jul 2009 11:45:40 +0000 (11:45 +0000)
2009-07-10  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/40496
* tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Create
the PHI result with a compatible type.

* g++.dg/opt/pr40496.C: New testcase.

From-SVN: r149469

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr40496.C [new file with mode: 0644]
gcc/tree-ssa-loop-manip.c

index 4c95fb3..684b6cd 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-10  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/40496
+       * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Create
+       the PHI result with a compatible type.
+
 2009-07-10  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR 25509
index 651afbf..4cb3306 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-10  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/40496
+       * g++.dg/opt/pr40496.C: New testcase.
+
 2009-07-10  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR 25509
diff --git a/gcc/testsuite/g++.dg/opt/pr40496.C b/gcc/testsuite/g++.dg/opt/pr40496.C
new file mode 100644 (file)
index 0000000..b0eaebf
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-options "-O2 -fprefetch-loop-arrays -msse2" { target i?86-*-* x86_64-*-* } }
+
+struct DOMStringHandle
+{
+  unsigned int fLength;
+  int fRefCount;
+};
+static void *freeListPtr;
+void foo(DOMStringHandle *dsg)
+{
+  int i;
+  for (i = 1; i < 1023; i++)
+    {
+      *(void **) &dsg[i] = freeListPtr;
+      freeListPtr = &dsg[i];
+    }
+}
index c1514bf..b891ea6 100644 (file)
@@ -990,10 +990,19 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
       /* Prefer using original variable as a base for the new ssa name.
         This is necessary for virtual ops, and useful in order to avoid
         losing debug info for real ops.  */
-      if (TREE_CODE (next) == SSA_NAME)
+      if (TREE_CODE (next) == SSA_NAME
+         && useless_type_conversion_p (TREE_TYPE (next),
+                                       TREE_TYPE (init)))
        var = SSA_NAME_VAR (next);
-      else if (TREE_CODE (init) == SSA_NAME)
+      else if (TREE_CODE (init) == SSA_NAME
+              && useless_type_conversion_p (TREE_TYPE (init),
+                                            TREE_TYPE (next)))
        var = SSA_NAME_VAR (init);
+      else if (useless_type_conversion_p (TREE_TYPE (next), TREE_TYPE (init)))
+       {
+         var = create_tmp_var (TREE_TYPE (next), "unrinittmp");
+         add_referenced_var (var);
+       }
       else
        {
          var = create_tmp_var (TREE_TYPE (init), "unrinittmp");