]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/46076 (constant propagation and compile-time math no longer...
authorRichard Guenther <rguenther@suse.de>
Tue, 11 Jan 2011 17:01:37 +0000 (17:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 11 Jan 2011 17:01:37 +0000 (17:01 +0000)
2011-01-11  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46076
* tree-ssa.c (useless_type_conversion_p): Conversions from
unprototyped to empty argument list function types are useless.

* gcc.dg/tree-ssa/pr46076.c: New testcase.

From-SVN: r168665

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr46076.c [new file with mode: 0644]
gcc/tree-ssa.c

index 35b4a696a28a6c13b61fb79b1b3710890c11f563..9724eee777d8c24d5fdda98c93f14b3bd7d02f68 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-11  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46076
+       * tree-ssa.c (useless_type_conversion_p): Conversions from
+       unprototyped to empty argument list function types are useless.
+
 2011-01-11  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/45235
index 710431c8424bb277dd16fce8cf37b6350b37c602..adb6740e58a79b4911ed0250e0b1a011e3b9fce1 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-11  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46076
+       * gcc.dg/tree-ssa/pr46076.c: New testcase.
+
 2011-01-11  Jeff Law <law@redhat.com>
 
        * PR tree-optimization/47086
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr46076.c b/gcc/testsuite/gcc.dg/tree-ssa/pr46076.c
new file mode 100644 (file)
index 0000000..a2777a6
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+extern void link_error (void);
+
+typedef unsigned char(*Calculable)(void);
+
+static unsigned char one() { return 1; }
+static unsigned char two() { return 2; }
+
+static int
+print(Calculable calculate)
+{
+  return calculate() + calculate() + 1;
+}
+
+int
+main()
+{
+  /* Make sure we perform indirect inlining of one and two and optimize
+     the result to a constant.  */
+  if (print(one) != 3)
+    link_error ();
+  if (print(two) != 5)
+    link_error ();
+  return 0;
+}
index 7bd01f8d4dbac7f023d8ce50fedaacd6d56f4d0e..aa797e22bec7bece2f89f8b2defe2fdb7e53b2b2 100644 (file)
@@ -1410,6 +1410,11 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
       if (!prototype_p (outer_type))
        return true;
 
+      /* A conversion between unprototyped and empty argument list is ok.  */
+      if (TYPE_ARG_TYPES (outer_type) == void_list_node
+         && !prototype_p (inner_type))
+       return true;
+
       /* If the unqualified argument types are compatible the conversion
         is useless.  */
       if (TYPE_ARG_TYPES (outer_type) == TYPE_ARG_TYPES (inner_type))
This page took 0.080723 seconds and 5 git commands to generate.