This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[GSoC][match-and-simplify] Add abs_expr pattern
- 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: Tue, 12 Aug 2014 04:28:19 +0530
- Subject: [GSoC][match-and-simplify] Add abs_expr pattern
- Authentication-results: sourceware.org; auth=none
Add pattern: abs (abs (x)) -> abs (x)
* match.pd: Add new pattern.
[gcc/testsuite/gcc.dg/tree-ssa]
* match.c: New test-case.
Thanks,
Prathamesh
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 213814)
+++ gcc/match.pd (working copy)
@@ -101,6 +101,12 @@ along with GCC; see the file COPYING3.
(fma INTEGER_CST_P@0 INTEGER_CST_P@1 @3)
(plus (mult @0 @1) @3))
+/* abs (abs (x)) -> abs (x) */
+(simplify
+ (abs (abs @0))
+ (abs @0))
+
+
#include "match-plusminus.pd"
#include "match-bitwise.pd"
#include "match-rotate.pd"
Index: gcc/testsuite/gcc.dg/tree-ssa/match.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/match.c (revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/match.c (working copy)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-forwprop1-details" } */
+
+int abs(int);
+
+int match_1 (int x)
+{
+ int t1 = abs (x);
+ int match_1_val = abs (t1);
+ return match_1_val;
+}
+/* { dg-final { scan-tree-dump "gimple_simplified to match_1_val_\\d\+ = ABS_EXPR <x_\\d\+\\(D\\)" "forwprop1" } } */
+
+/* { dg-final { cleanup-tree-dump "forwprop1" } } */