This is the mail archive of the gcc@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]

[GSoC] writing test-case


Hi,
    I was trying to write test-case for the pattern A + -B -> A - B
(currently written for only int type).
Is the test-case written correctly (attached) ?

a) I am not able to follow why 3 slashes are required here
in x_.\\\(D\\\) ? Why does x_.\(D\) not work ?
(I saw 3 slashes used in a testcase in forwprop-8.c and wrote the
test-case accordingly).

b) The expression after folding would be of the form:
t2_<digit> = x_<digit>(D) - y_<digit>(D)
I have used the operator "." in the pattern to match digit.
While that works in the above case, I think a better
idea would be to match using [0-9].
I tried the following but it does not work:
t_[0-9] = x_[0-9]\\\(D\\\) - y_[0-9]\\\(D\\\)
Neither does \\\[ and \\\] work.

I guess writing test-cases for other patterns in match.pd would be similar.
If this test-case is correct, I shall proceed to writing test-cases
for other patterns
in match.pd and trigger each test-case from forwprop.

Thanks and Regards,
Prathamesh
Index: gcc/testsuite/gcc.dg/tree-ssa/match-2.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/match-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/match-2.c	(working copy)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-forwprop" }  */
+
+int foo(int x, int y)
+{
+  int t1, t2;
+  t1 = -y;
+  t2 = x + t1;
+  return t2;
+}
+
+/* { dg-final { scan-tree-dump-times "t2_. = x_.\\\(D\\\) - y_.\\\(D\\\)" 1 "forwprop1" } } */
+/* { dg-final { cleanup-tree-dump "forwprop2" } } */

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