[testsuite, pretty-ipa?] Changes to gcc.dg/ipa tests so that they pass on pretty-ipa
Martin Jambor
mjambor@suse.cz
Wed Mar 24 15:20:00 GMT 2010
Hi,
On Wed, Mar 24, 2010 at 03:05:40PM +0100, Jan Hubicka wrote:
> Well, the ipa-cost testcases were mostly meant to test that we don't duplicate
> too much not that we are able to solve the ipa-cp problem.
Are we? ;-)
> I would still
> preffer the testcases to be in the more complex form (i.e. involving clonning)
> so they test more. I.e. they test that cost model is sane, that ipa-profile is
> not mistakely marking the functions as cold when they are inside loop and that
> ipa-cp does its job including duplicatio nas well.
OK, the modified patch is below. It now also contains modifications
to g++.dg/ipa/iinline-1.C since that testcase falls into the same
category.
> It may make sense to add a testcase that clonning does not happen when function
> is discovered to be cold (called once) by ipa-profile
OK, that however cannot be added to trunk at the moment so I did not
attempt it.
> and that we still propagate without duplication for function
> disovered as cold that both should work at pretty-ipa.
If you mean that we should also propagate constants to static
functions even if they have no hot calls then the test added below as
gcc.dg/ipa/ipa-8.c does exactly that.
BTW, the rest of the failures seem to be caused by the fact that main
is considered to be cold and there is no interprocedural element to
it. Thus I intend to "fix" them by marking main with the hot
attribute.
I have tested the patch on trunk on i686-linux by running the modified
testcases from within make check. OK for trunk?
Thanks,
Martin
2010-03-24 Martin Jambor <mjambor@suse.cz>
* gcc.dg/ipa/ipa-1.c: Delete trailing spaces, put the call to f into
a loop.
* gcc.dg/ipa/ipa-2.c: Likewise.
* gcc.dg/ipa/ipa-3.c: Likewise.
* gcc.dg/ipa/ipa-4.c: Likewise.
* gcc.dg/ipa/ipa-5.c: Likewise.
* gcc.dg/ipa/ipa-7.c: Likewise.
* gcc.dg/ipa/ipa-6.c: Delete trailing spaces, put the call to foo into
a loop.
* gcc.dg/ipa/ipacost-2.c: Delete trailing spaces, put the call to
i_can_not_be_propagated_fully2 into a loop.
* gcc.dg/ipa/ipa-8.c: New test.
* g++.dg/ipa/iinline-1.C: Put the call to docalling into a loop.
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-1.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-1.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-1.c
@@ -13,12 +13,14 @@ int f (int a)
if (a > 0)
g (a, 3);
else
- g (a, 5);
+ g (a, 5);
}
int main ()
{
- f (7);
- return 0;
+ int i;
+ for (i = 0; i < 100; i++)
+ f (7);
+ return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-2.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-2.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-2.c
@@ -15,8 +15,10 @@ int f (int a)
}
int main ()
{
- f (7);
- return 0;
+ int i;
+ for (i = 0; i < 100; i++)
+ f (7);
+ return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-3.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-3.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-3.c
@@ -10,19 +10,21 @@ void t(void);
int g (double b, double c)
{
t();
- return (int)(b+c);
+ return (int)(b+c);
}
int f (double a)
{
if (a > 0)
g (a, 3.1);
else
- g (a, 3.1);
+ g (a, 3.1);
}
int main ()
{
- f (7.44);
- return 0;
+ int i;
+ for (i = 0; i < 100; i++)
+ f (7.44);
+ return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-4.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-4.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-4.c
@@ -9,17 +9,19 @@ int g (int b, int c)
}
int f (int a)
{
- /* First and second parameter of g gets different values. */
-
+ /* First and second parameter of g gets different values. */
+
if (a > 0)
g (a, 3);
else
- g (a+1, 5);
+ g (a+1, 5);
}
int main ()
{
- f (7);
- return 0;
+ int i;
+ for (i = 0; i < 100; i++)
+ f (7);
+ return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-5.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-5.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-5.c
@@ -20,8 +20,10 @@ int f (float a)
}
int main ()
{
- f (7.6);
- return 0;
+ int i;
+ for (i = 0; i < 100; i++)
+ f (7.6);
+ return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-6.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-6.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-6.c
@@ -23,7 +23,9 @@ foo (int a)
int
main ()
{
- foo (7);
+ int i;
+ for (i = 0; i < 100; i++)
+ foo (7);
return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-7.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipa-7.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-7.c
@@ -13,14 +13,16 @@ int f (int a)
if (a > 0)
g (a, 3);
else
- g (a, 5);
-
+ g (a, 5);
+
send_addr (&a);
}
int main ()
{
- f (7);
- return 0;
+ int i;
+ for (i = 0; i < 100; i++)
+ f (7);
+ return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipacost-2.c
===================================================================
--- pipa.orig/gcc/testsuite/gcc.dg/ipa/ipacost-2.c
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipacost-2.c
@@ -6,7 +6,7 @@ int array[100];
int t(int);
-static int
+static int
i_can_be_propagated_fully (int *a)
{
int i;
@@ -18,14 +18,14 @@ i_can_be_propagated_fully (int *a)
t(a[i+3]);
}
}
-static int
+static int
i_can_be_propagated_fully2 (int *a)
{
i_can_be_propagated_fully (a);
i_can_be_propagated_fully (a);
i_can_be_propagated_fully (a);
}
-static int
+static int
i_can_not_be_propagated_fully (int *a)
{
int i;
@@ -37,7 +37,7 @@ i_can_not_be_propagated_fully (int *a)
t(a[i+3]);
}
}
-int
+int
i_can_not_be_propagated_fully2 (int *a)
{
i_can_not_be_propagated_fully (a);
@@ -46,9 +46,12 @@ i_can_not_be_propagated_fully2 (int *a)
}
main()
{
+ int i;
i_can_be_propagated_fully2 (array);
i_can_be_propagated_fully2 (array);
- i_can_not_be_propagated_fully2 (array);
+
+ for (i = 0; i < 100; i++)
+ i_can_not_be_propagated_fully2 (array);
i_can_not_be_propagated_fully2 (array);
}
Index: pipa/gcc/testsuite/g++.dg/ipa/iinline-1.C
===================================================================
--- pipa.orig/gcc/testsuite/g++.dg/ipa/iinline-1.C
+++ pipa/gcc/testsuite/g++.dg/ipa/iinline-1.C
@@ -38,8 +38,9 @@ int docalling (int (String::* f)(int del
int main (int argc, char *argv[])
{
- int i;
- i = docalling (&String::funcOne);
+ int i = 0;
+ while (i < 1000)
+ i += docalling (&String::funcOne);
non_existent ("done", i);
return 0;
}
Index: pipa/gcc/testsuite/gcc.dg/ipa/ipa-8.c
===================================================================
--- /dev/null
+++ pipa/gcc/testsuite/gcc.dg/ipa/ipa-8.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fipa-cp -fipa-cp-clone -fdump-ipa-cp -fno-early-inlining" } */
+/* { dg-add-options bind_pic_locally } */
+
+#include <stdio.h>
+static int g (int b, int c)
+{
+ printf ("%d %d\n", b, c);
+}
+static int f (int a)
+{
+ /* Second parameter of g gets different values. */
+ if (a > 0)
+ g (a, 3);
+ else
+ g (a, 5);
+}
+int main ()
+{
+ f (7);
+ return 0;
+}
+
+
+/* { dg-final { scan-ipa-dump-times "versioned function" 2 "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param b with const 7" "cp" } } */
+/* { dg-final { cleanup-ipa-dump "cp" } } */
+
+
More information about the Gcc-patches
mailing list