re PR tree-optimization/14736 ([tree-ssa] code quality regression)
authorAndrew Pinski <pinskia@physics.uc.edu>
Wed, 2 Jun 2004 18:56:54 +0000 (18:56 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Wed, 2 Jun 2004 18:56:54 +0000 (11:56 -0700)
2004-06-02  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-optimization/14736
        * g++.dg/tree-ssa/ssa-cast-1.C: New Test.

        PR tree-optimization/14042
        * g++.dg/tree-ssa/ssa-sra-1.C: New Test.

        PR tree-optimization/14729
        * g++.dg/tree-ssa/ssa-sra-2.C: New Test.

2004-06-02  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-optimization/14042
        PR tree-optimization/14729
        PR tree-optimization/14736
        * tree-ssa.c: Check the type which the pointer points to
        instead of the pointer types.

From-SVN: r82573

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

index 8d22422d99361343b564060715c7133fee9b380f..7290effa578f9913dd7acde11c012a3e16e79747 100644 (file)
@@ -1,3 +1,11 @@
+2004-06-02  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-optimization/14042
+       PR tree-optimization/14729
+       PR tree-optimization/14736
+       * tree-ssa.c: Check the type which the pointer points to
+       instead of the pointer types.
+
 2004-06-02  Kazu Hirata  <kazu@cs.umass.edu>
 
        PR tree-optimization/15738.
index 2a8bc4a6c94cd44a4f12a19650db7b5f5e4f429d..4f4dd345151b6c96a4ba767eaeeb44c22d5c661b 100644 (file)
@@ -1,3 +1,14 @@
+2004-06-02  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-optimization/14736
+       * g++.dg/tree-ssa/ssa-cast-1.C: New Test.
+       
+       PR tree-optimization/14042
+       * g++.dg/tree-ssa/ssa-sra-1.C: New Test.
+
+       PR tree-optimization/14729
+       * g++.dg/tree-ssa/ssa-sra-2.C: New Test.
+
 2004-06-02  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/15557
diff --git a/gcc/testsuite/g++.dg/tree-ssa/ssa-cast-1.C b/gcc/testsuite/g++.dg/tree-ssa/ssa-cast-1.C
new file mode 100644 (file)
index 0000000..b801587
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-vars" } */
+
+int &f(int *a)
+{
+  return *a;
+}
+
+/* There should be no cast as pointer and references are
+   considered the same type. */
+/* { dg-final { scan-tree-dump-times "\\(int &\\)" 0 "vars"} } */
+
diff --git a/gcc/testsuite/g++.dg/tree-ssa/ssa-sra-1.C b/gcc/testsuite/g++.dg/tree-ssa/ssa-sra-1.C
new file mode 100644 (file)
index 0000000..cf6c520
--- /dev/null
@@ -0,0 +1,60 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-vars-details" } */
+
+void link_error();
+
+
+struct State {
+    int p0, p1, p2;
+    inline State(){p0=0;p1=0;p2=0;}
+    inline State(const State &s) {
+       p0 = s.p0;
+       p1 = s.p1;
+       p2 = s.p2;
+    }
+    
+    inline void operator =(const State &s) {
+       p0 = s.p0;
+       p1 = s.p1;
+       p2 = s.p2;
+    }
+    
+    inline void step(void) {
+       p0 = p1+p2;
+       p1 = p0*p1+p2;
+       p2 = p0-p2;
+    }
+};
+
+
+inline void iterate_ok(State &inS1, State &inS2, unsigned int n)
+{
+    State s1 = inS1;
+    for (unsigned int i = 0; i < n; i++) {
+       s1.step();
+    }
+    inS1 = s1;
+}
+
+void temp()
+{
+  State s1;
+  s1.p0 = 0;
+  s1.p1 = 0;
+  s1.p2 = 0;
+  State s2;
+  s2.p0 = 0;
+  s2.p1 = 0;
+  s2.p2 = 0;
+  iterate_ok (s1, s2, 1);
+  if (s1.p0)
+   link_error();
+  if (s1.p0)
+   link_error();
+  if (s1.p0)
+   link_error();
+}
+
+/* We should removed the casts from pointers to references and caused SRA to happen.  */
+
+/* { dg-final { scan-tree-dump-times "link_error" 0 "vars"} } */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/ssa-sra-2.C b/gcc/testsuite/g++.dg/tree-ssa/ssa-sra-2.C
new file mode 100644 (file)
index 0000000..0d63752
--- /dev/null
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-vars-details" } */
+
+void link_error();
+
+struct OOf {
+        int value;
+        OOf() {value = 0;}
+};
+inline OOf operator+(OOf op1, OOf op2)
+{
+        OOf f;
+        f.value = op1.value + op2.value;
+        return f;
+}
+inline OOf operator*(OOf op1, OOf op2)
+{
+        OOf f;
+        f.value = op1.value * op2.value;
+        return f;
+}
+inline OOf operator-(OOf op1, OOf op2)
+{
+        OOf f;
+        f.value = op1.value - op2.value;
+        return f;
+}
+inline OOf test_func(
+        OOf a,
+        OOf b,
+        OOf c
+)
+{
+        OOf d, e;
+        OOf result;
+        d = a * b + b * c;
+        e = a * c - b * d;
+        result = d * e;
+        return result;
+}
+
+void test()
+{
+  OOf a, b, c;
+  OOf d = test_func (a,b,c);
+  if (d.value)
+    link_error();
+}
+
+/* We should removed the casts from pointers to references and caused SRA to happen.  */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "vars"} } */
index 8ecce07e4f4dd8118ad0e57678c996bc177838de..99e2cb64dfd7309e4403b870b5328f95a88ecead 100644 (file)
@@ -555,7 +555,8 @@ tree_ssa_useless_type_conversion_1 (tree outer_type, tree inner_type)
      so strip conversions that just switch between them.  */
   else if (POINTER_TYPE_P (inner_type)
            && POINTER_TYPE_P (outer_type)
-           && lang_hooks.types_compatible_p (inner_type, outer_type))
+           && lang_hooks.types_compatible_p (TREE_TYPE (inner_type),
+                                            TREE_TYPE (outer_type)))
     return true;
 
   /* If both the inner and outer types are integral types, then the