This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[GSoC][match-and-simplify] add few constant-folding tests
- From: Prathamesh Kulkarni <bilbotheelffriend at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>, Maxim Kuvyrkov <maxim dot kuvyrkov at linaro dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 13 Aug 2014 01:38:15 +0530
- Subject: [GSoC][match-and-simplify] add few constant-folding tests
- Authentication-results: sourceware.org; auth=none
[gcc/testsuite/gcc.dg/tree-ssa]
* match-constant-folding.c: New test-case.
Thanks,
Prathamesh
Index: gcc/testsuite/gcc.dg/tree-ssa/match-constant-folding.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/match-constant-folding.c (revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/match-constant-folding.c (working copy)
@@ -0,0 +1,58 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-ccp-details -fdump-tree-forwprop-details" } */
+
+/* x + 0 -> x */
+int c1(int x)
+{
+ int t1 = 0;
+ int c1_val = x + t1;
+ return c1_val;
+}
+/* { dg-final { scan-tree-dump "Match-and-simplified x_\\d\+\\(D\\) \\+ t1_\\d\+ to x_\\d\+\\(D\\)" "ccp1" } } */
+
+/* x ptrplus 0 -> x */
+char *c2(char *p)
+{
+ int t1 = 0;
+ char *c2_val = p + t1;
+ return c2_val;
+}
+/* { dg-final { scan-tree-dump "Match-and-simplified p_\\d\+\\(D\\) \\+ _\\d\+ to p_\\d\+\\(D\\)" "ccp1" } } */
+
+/* x - 0 -> x */
+int c3(int x)
+{
+ int t1 = 0;
+ int c3_val = x - t1;
+ return c3_val;
+}
+/* { dg-final { scan-tree-dump "Match-and-simplified x_\\d\+\\(D\\) - t1_\\d\+ to x_\\d\+\\(D\\)" "ccp1" } } */
+
+/* x - x -> 0 */
+int c4(int x)
+{
+ int t1 = x;
+ int c4_val = x - t1;
+ return c4_val;
+}
+/* { dg-final { scan-tree-dump "gimple_simplified to c4_val_\\d\+ = 0" "forwprop1" } } */
+
+/* x * 0 -> 0 */
+int c5(int x)
+{
+ int t1 = 0;
+ int c5_val = x * t1;
+ return c5_val;
+}
+/* { dg-final { scan-tree-dump "Match-and-simplified x_\\d\+\\(D\\) \\* t1_\\d\+ to 0" "ccp1" } } */
+
+/* x * 1 -> x */
+int c6(int x)
+{
+ int t1 = 1;
+ int c6_val = x * t1;
+ return c6_val;
+}
+/* { dg-final { scan-tree-dump "Match-and-simplified x_\\d\+\\(D\\) \\* t1_\\d\+ to x_\\d\+\\(D\\)" "ccp1" } } */
+
+/* { dg-final { cleanup-tree-dump "forwprop2" } } */