This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add inliner related testcases


Hi,
these PRs was fixed by ipa-reference work, but it is useful to have some testing coverage.

Honza

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 166555)
+++ ChangeLog	(working copy)
@@ -1,5 +1,12 @@
 2010-11-10  Jan Hubicka  <jh@suse.cz>
 
+	PR tree-optimize/33172
+	PR tree-optimize/43411
+	* gcc.dg/tree-ssa/pr33172.c: New testcase.
+	* g++.dg/tree-ssa/pr43411.C: New testcase.
+
+2010-11-10  Jan Hubicka  <jh@suse.cz>
+
 	PR tree-optimize/46228
 	* g++.dg/tree-ssa/pr46228.C: New testcase.
 
Index: gcc.dg/tree-ssa/pr33172.c
===================================================================
--- gcc.dg/tree-ssa/pr33172.c	(revision 0)
+++ gcc.dg/tree-ssa/pr33172.c	(revision 0)
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+struct abc {
+    void (*abc_call)(void);
+};
+
+/*
+ * Use only any one of the three definitions below at a time:
+ *
+ * 1. nothing optimized away. Good.
+ * 2. call_func() _not_ optimized away, but struct xyz is. gcc disappoints.
+ * 3. both call_func() and struct xyz optimized away. Nice.
+ */
+
+/* 1 */
+/*extern int do_register(struct abc *xyz);*/
+
+/* 2 */
+static inline int do_register(struct abc *xyz)
+{
+    return 0;
+}
+
+/* 3 */
+/*#define do_register(xyz)    do { (void)(xyz); } while (0)*/
+
+static void call_func(void)
+{
+}
+
+static struct abc xyz = {
+    .abc_call = call_func,
+};
+
+void func(void)
+{
+    do_register(&xyz);
+}
+
+/* { dg-final { scan-tree-dump-not "call_func" "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: g++.dg/tree-ssa/pr43411.C
===================================================================
--- g++.dg/tree-ssa/pr43411.C	(revision 0)
+++ g++.dg/tree-ssa/pr43411.C	(revision 0)
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+class P { public: virtual int val() { return 123; } };
+class Psub : public P { };
+
+extern int sink1, sink2;
+
+void test() {
+    Psub p;
+    P &pRef = p;
+    sink1 = p.val();
+    sink2 = pRef.val();
+}
+
+
+inline int v(P &p) { return p.val(); }
+
+void testInlineP() {
+    P p;
+    sink1 = v(p);
+}
+
+void testInlinePsub() {
+    Psub p;
+    sink1 = v(p);
+}
+
+// { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]