aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2004-06-02 18:56:54 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2004-06-02 11:56:54 -0700
commit3facc4b61545614e75b4fb852a72bbc80554705b (patch)
treec7fccbaf60e8db73bde589527b1620708b2c614b
parent91fa0e3de67af533eeeb8ef494a2bb66187570c1 (diff)
downloadgcc-3facc4b61545614e75b4fb852a72bbc80554705b.zip
gcc-3facc4b61545614e75b4fb852a72bbc80554705b.tar.gz
gcc-3facc4b61545614e75b4fb852a72bbc80554705b.tar.bz2
re PR tree-optimization/14736 ([tree-ssa] code quality regression)
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
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/ssa-cast-1.C12
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/ssa-sra-1.C60
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/ssa-sra-2.C51
-rw-r--r--gcc/tree-ssa.c3
6 files changed, 144 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8d22422..7290eff 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2a8bc4a..4f4dd34 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..b801587
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/ssa-cast-1.C
@@ -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
index 0000000..cf6c520
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/ssa-sra-1.C
@@ -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
index 0000000..0d63752
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/ssa-sra-2.C
@@ -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"} } */
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 8ecce07..99e2cb6 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -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