public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [GSoC][match-and-simplify] Add abs_expr pattern
@ 2014-08-11 22:58 Prathamesh Kulkarni
  2014-08-12 11:26 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Prathamesh Kulkarni @ 2014-08-11 22:58 UTC (permalink / raw)
  To: Richard Biener, Maxim Kuvyrkov, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 147 bytes --]

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

[-- Attachment #2: abs_expr.patch --]
[-- Type: text/x-patch, Size: 1077 bytes --]

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" } } */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [GSoC][match-and-simplify] Add abs_expr pattern
  2014-08-11 22:58 [GSoC][match-and-simplify] Add abs_expr pattern Prathamesh Kulkarni
@ 2014-08-12 11:26 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2014-08-12 11:26 UTC (permalink / raw)
  To: Prathamesh Kulkarni; +Cc: Maxim Kuvyrkov, gcc-patches

On Tue, Aug 12, 2014 at 12:58 AM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> Add pattern: abs (abs (x)) -> abs (x)
>
> * match.pd: Add new pattern.

Thanks - applied.

Richard.

> [gcc/testsuite/gcc.dg/tree-ssa]
> * match.c: New test-case.
>
> Thanks,
> Prathamesh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-12 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-11 22:58 [GSoC][match-and-simplify] Add abs_expr pattern Prathamesh Kulkarni
2014-08-12 11:26 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).