]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/49911 (SRA + DOM + VRP + -fstrict-enums incorrectly remove...
authorMartin Jambor <mjambor@suse.cz>
Thu, 8 Sep 2011 17:20:52 +0000 (19:20 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 8 Sep 2011 17:20:52 +0000 (19:20 +0200)
2011-09-08  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/49911
* tree-sra.c (analyze_access_subtree): Change type of to-be-replaced
enumerations to the corresponding plain integer type.

* testsuite/g++.dg/tree-ssa/pr49911.C: New test.

From-SVN: r178701

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr49911.C [new file with mode: 0644]
gcc/tree-sra.c

index 59f0a7c06e44b8f2d67996eef554311da79d08ea..27d8169b47e11e54974f14f3ce53b92bb8657181 100644 (file)
@@ -1,3 +1,12 @@
+2011-09-08  Martin Jambor  <mjambor@suse.cz>
+
+       Backport from mainline
+       2011-09-07  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/49911
+       * tree-sra.c (analyze_access_subtree): Change type of to-be-replaced
+       enumerations to the corresponding plain integer type.
+
 2011-08-26  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR target/50090
index 3ec6da5174bdfb0255db472a8fe4bfc2485295f8..2aeaed6b80c495e9da892cb5ce8be05905981fea 100644 (file)
@@ -1,3 +1,11 @@
+2011-09-08  Martin Jambor  <mjambor@suse.cz>
+
+       Backport from mainline
+       2011-09-07  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/49911
+       * g++.dg/tree-ssa/pr49911.C: New test.
+
 2011-09-01  Mikael Morin  <mikael.morin@sfr.fr>
 
        PR fortran/50050
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr49911.C b/gcc/testsuite/g++.dg/tree-ssa/pr49911.C
new file mode 100644 (file)
index 0000000..b96f5f5
--- /dev/null
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-rtti -fno-exceptions -fno-strict-aliasing -fdump-tree-vrp2" } */
+
+
+extern  void JS_Assert();
+typedef enum {
+eax,         ecx,         edx,         ebx,         esp,         ebp,
+esi,         edi     }
+RegisterID;
+union StateRemat {
+  RegisterID reg_;
+  int offset_;
+};
+static StateRemat FromRegister(RegisterID reg) {
+  StateRemat sr;
+  sr.reg_ = reg;
+  return sr;
+}
+static StateRemat FromAddress3(int address) {
+  StateRemat sr;
+    sr.offset_ = address;
+  //sr.offset_ = 0;
+  if (address < 46 &&    address >= 0) {
+    JS_Assert();
+  }
+  return sr;
+}
+struct FrameState {
+  StateRemat dataRematInfo2(bool y, int z) {
+    if (y)         return FromRegister(RegisterID(1));
+    return FromAddress3(z);
+  }
+};
+FrameState frame;
+StateRemat x;
+void jsop_setelem(bool y, int z) {
+  x = frame.dataRematInfo2(y, z);
+}
+
+/* { dg-final { scan-tree-dump-times "Folding predicate.*45" 0 "vrp2"} } */
+/* { dg-final { cleanup-tree-dump "vrp2" } } */
index 06d2cdf718135a156ce263ce93be8c614b6912ed..3326582814ab7618b69062e8c5c000ca21ed2643 100644 (file)
@@ -1854,13 +1854,25 @@ analyze_access_subtree (struct access *root, bool allow_replacements,
       && build_ref_for_offset (NULL, TREE_TYPE (root->base), root->offset,
                               root->type, false))
     {
+      bool new_integer_type;
+      if (TREE_CODE (root->type) == ENUMERAL_TYPE)
+       {
+         tree rt = root->type;
+         root->type = build_nonstandard_integer_type (TYPE_PRECISION (rt),
+                                                      TYPE_UNSIGNED (rt));
+         new_integer_type = true;
+       }
+      else
+       new_integer_type = false;
+
       if (dump_file && (dump_flags & TDF_DETAILS))
        {
          fprintf (dump_file, "Marking ");
          print_generic_expr (dump_file, root->base, 0);
-         fprintf (dump_file, " offset: %u, size: %u: ",
+         fprintf (dump_file, " offset: %u, size: %u ",
                   (unsigned) root->offset, (unsigned) root->size);
-         fprintf (dump_file, " to be replaced.\n");
+         fprintf (dump_file, " to be replaced%s.\n",
+                  new_integer_type ? " with an integer": "");
        }
 
       root->grp_to_be_replaced = 1;