From patchwork Sun Jul 6 19:45:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 367394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C81F71400D3 for ; Mon, 7 Jul 2014 05:45:24 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=OrRJmBSEpOhsOa5LwcrFteHkpad6UEoiwVzrTmkCHcky7O sRxFGxOfereOVYlVDaElQE8fGbkgMdkI+NQRluWUlUp6P1/AfnfhPb8D29/0otxg 7KMXLIZPTCNywxJ24U+cw658Jc4xFXUbYmn08i+ijBVI5wCnX4Nyf01fTVQmg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=ZI5lgsET4yMVOcwZ34MIXn/qT1k=; b=ctaGuv7dcWeBgmYiceIZ cZZ3wtP3iN8rJxOPb2UjqUsaLfShIeOUN4L55gVucWxIoSSaupVSXvdou7p3/y2J wnuSdcfopyVjpFkso/8qcsprcM83h1fCcwWgZryQnDwWQ5q/CETRtbn3C4/2NvUb 3fYOiZVQkDC07emYb+c32Ho= Received: (qmail 11497 invoked by alias); 6 Jul 2014 19:45:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11456 invoked by uid 89); 6 Jul 2014 19:45:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f177.google.com Received: from mail-ob0-f177.google.com (HELO mail-ob0-f177.google.com) (209.85.214.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 06 Jul 2014 19:45:10 +0000 Received: by mail-ob0-f177.google.com with SMTP id uy5so3542904obc.8 for ; Sun, 06 Jul 2014 12:45:07 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.125.195 with SMTP id ms3mr26176629oeb.40.1404675907670; Sun, 06 Jul 2014 12:45:07 -0700 (PDT) Received: by 10.182.113.67 with HTTP; Sun, 6 Jul 2014 12:45:07 -0700 (PDT) Date: Mon, 7 Jul 2014 01:15:07 +0530 Message-ID: Subject: [GSoC][match-and-simplify] add few test-cases From: Prathamesh Kulkarni To: Richard Biener , Diego Novillo , "gcc-patches@gcc.gnu.org" , Maxim Kuvyrkov X-IsSubscribed: yes Hi, This patch adds few test-cases for gimple match-and-simplfiy and removes match-2.c [gcc/testsuite/gcc.dg/tree-ssa] * match-2.c: Remove. * match-plusminus.c: New test-case. * match-bitwise.c: Likewise. * match-realimag.c: Likewise. Thanks and Regards, Prathamesh Index: gcc/testsuite/gcc.dg/tree-ssa/match-2.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/match-2.c (revision 212038) +++ gcc/testsuite/gcc.dg/tree-ssa/match-2.c (working copy) @@ -1,211 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-forwprop-details" } */ - -/* x + (-y) -> x - y */ -int f1(int x, int y) -{ - int t1 = -y; - return x + t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\) - y_\\d\+\\(D\\)" "forwprop1" } } */ - -/* x - (-y) -> y + x */ -int f2(int x, int y) -{ - int t1 = -y; - return x - t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= y_\\d\+\\(D\\) \\+ x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x + y) - x -> y */ -int f3(int x, int y) -{ - int t1 = x + y; - return t1 - x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= y_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x - y) - x -> -y */ -int f4(int x, int y) -{ - int t1 = x - y; - return t1 - x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= -y_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x + y) - y -> x */ -int f5(int x, int y) -{ - int t1 = x + y; - return t1 - y; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x - y) + y -> x */ -int f6(int x, int y) -{ - int t1 = x - y; - return t1 + y; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x + cst1) + cst2 -> x + (cst1 + cst2) */ -int f7(int x) -{ - int t1 = x + 3; - return t1 + 4; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\) \\+ 7" "forwprop1" } } */ - -/* (cst1 - x) + cst2 -> (cst1 + cst2) - x */ -int f8(int x) -{ - int t1 = 3 - x; - return t1 + 4; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= 7 - x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x >> 31) & 1 -> x >> 31 */ -int f9(int x) -{ - int t1 = x >> 31; - return t1 & 1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= t1_\\d\+" "forwprop1" } } */ - -/* -(~x) -> x + 1 */ -int f10(int x) -{ - int t1, t2; - t1 = ~x; - t2 = -t1; - return t2; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\) \\+ 1" "forwprop1" } } */ - -/* x + ~x -> -1 */ -int f11(int x) -{ - int t1 = ~x; - return t1 + x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= -1" "forwprop1" } } */ - -/* ~x + 1 -> -x */ -int f12(int x) -{ - int t1 = ~x; - return t1 + 1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= -x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* __real complex (__real x) = x */ -double f13(double x) -{ - _Complex double t1 = x; - return __real t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* __imag complex (__imag x) = x */ -double f14(double x) -{ - _Complex double t1 = x; - return __imag t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* x & x -> x */ -int f15(int x) -{ - int t1 = x; - return t1 & x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* x & ~x -> 0 */ -int f16(int x) -{ - int t1 = ~x; - return t1 & x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= 0" "forwprop1" } } */ - -/* x ^ x -> 0 */ -int f17(int x) -{ - int t1 = x; - return t1 ^ x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= 0" "forwprop1" } } */ - -/* ~~x -> 0 */ -int f18(int x) -{ - int t1 = ~x; - return ~t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x | y) & x -> x */ -int f19(int x, int y) -{ - int t1 = x | y; - return t1 & x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (x & y) | x -> x */ -int f20(int x, int y) -{ - int t1 = x & y; - return t1 | x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (~x & y) | x -> x & y */ -int f21(int x, int y) -{ - int t1 = ~x; - int t2 = t1 & y; - return t2 | x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\) & y_\\d\+\\(D\\)" "forwprop1" } } */ - -/* (~x | y) & x -> x & y */ -int f22(int x, int y) -{ - int t1 = ~x; - int t2 = t1 | y; - return t2 & x; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\) & y_\\d\+\\(D\\)" "forwprop1" } } */ - -/* ((x & y) & ~x) & ~y -> 0 */ -int f23(int x, int y) -{ - int t1 = x & y; - int t2 = ~x; - int t3 = t1 & t2; - int t4 = ~y; - return t3 & t4; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= 0" "forwprop1" } } */ - -/* x & 0 -> 0 */ -int f24(int x) -{ - int t1 = 0; - return x & t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= 0" "forwprop1" } } */ - -/* x & -1 -> x */ -int f25(int x) -{ - int t1 = -1; - return x & t1; -} -/* { dg-final { scan-tree-dump "gimple_match_and_simplified to \[^\n\r\]*= x_\\d\+\\(D\\)" "forwprop1" } } */ - -/* { dg-final { cleanup-tree-dump "forwprop2" } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/match-plusminus.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/match-plusminus.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/match-plusminus.c (working copy) @@ -0,0 +1,76 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-forwprop-details" } */ + +/* x + (-y) -> x - y */ +int plusminus_1(int x, int y) +{ + int t1 = -y; + int plusminus_1_val = x + t1; + return plusminus_1_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_1_val_\\d\+ = x_\\d\+\\(D\\) - y_\\d\+\\(D\\)" "forwprop1" } } */ + +/* x - (-y) -> y + x */ +int plusminus_2(int x, int y) +{ + int t1 = -y; + int plusminus_2_val = x - t1; + return plusminus_2_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_2_val_\\d\+ = y_\\d\+\\(D\\) \\+ x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x + y) - x -> y */ +int plusminus_3(int x, int y) +{ + int t1 = x + y; + int plusminus_3_val = t1 - x; + return plusminus_3_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_3_val_\\d\+ = y_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x - y) - x -> -y */ +int plusminus_4(int x, int y) +{ + int t1 = x - y; + int plusminus_4_val = t1 - x; + return plusminus_4_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_4_val_\\d\+ = -y_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x + y) - y -> x */ +int plusminus_5(int x, int y) +{ + int t1 = x + y; + int plusminus_5_val = t1 - y; + return plusminus_5_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_5_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x - y) + y -> x */ +int plusminus_6(int x, int y) +{ + int t1 = x - y; + int plusminus_6_val = t1 + y; + return plusminus_6_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_6_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x + cst1) + cst2 -> x + (cst1 + cst2) */ +int plusminus_7(int x) +{ + int t1 = x + 3; + int plusminus_7_val = t1 + 4; + return plusminus_7_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_7_val_\\d\+ = x_\\d\+\\(D\\) \\+ 7" "forwprop1" } } */ + +/* (cst1 - x) + cst2 -> (cst1 + cst2) - x */ +int plusminus_8(int x) +{ + int t1 = 3 - x; + int plusminus_8_val = t1 + 4; + return plusminus_8_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to plusminus_8_val_\\d\+ = 7 - x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* { dg-final { cleanup-tree-dump "forwprop2" } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/match-bitwise.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/match-bitwise.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/match-bitwise.c (working copy) @@ -0,0 +1,88 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-forwprop-details" } */ + +/* x & x -> x */ +int bitwise_1(int x) +{ + int t1 = x; + int bitwise_1_val = t1 & x; + return bitwise_1_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_1_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* x & ~x -> 0 */ +int bitwise_2(int x) +{ + int t1 = ~x; + int bitwise_2_val = t1 & x; + return bitwise_2_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_2_val_\\d\+ = 0" "forwprop1" } } */ + +/* x ^ x -> 0 */ +int bitwise_3(int x) +{ + int t1 = x; + int bitwise_3_val = t1 ^ x; + return bitwise_3_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_3_val_\\d\+ = 0" "forwprop1" } } */ + +/* ~~x -> 0 */ +int bitwise_4(int x) +{ + int t1 = ~x; + int bitwise_4_val = ~t1; + return bitwise_4_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_4_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x | y) & x -> x */ +int bitwise_5(int x, int y) +{ + int t1 = x | y; + int bitwise_5_val = t1 & x; + return bitwise_5_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_5_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (x & y) | x -> x */ +int bitwise_6(int x, int y) +{ + int t1 = x & y; + int bitwise_6_val = t1 | x; + return bitwise_6_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_6_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (~x & y) | x -> x | y */ +int bitwise_7(int x, int y) +{ + int t1 = ~x; + int t2 = t1 & y; + int bitwise_7_val = t2 | x; + return bitwise_7_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_7_val_\\d\+ = x_\\d\+\\(D\\) | y_\\d\+\\(D\\)" "forwprop1" } } */ + +/* (~x | y) & x -> x & y */ +int bitwise_8(int x, int y) +{ + int t1 = ~x; + int t2 = t1 | y; + int bitwise_8_val = t2 & x; + return bitwise_8_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_8_val_\\d\+ = x_\\d\+\\(D\\) & y_\\d\+\\(D\\)" "forwprop1" } } */ + +/* ((x & y) & ~x) & ~y -> 0 */ +int bitwise_9(int x, int y) +{ + int t1 = x & y; + int t2 = ~x; + int bitwise_9_val = t1 & t2; + return bitwise_9_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to bitwise_9_val_\\d\+ = 0" "forwprop1" } } */ + +/* { dg-final { cleanup-tree-dump "forwprop2" } } */ Index: gcc/testsuite/gcc.dg/tree-ssa/match-realimag.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/match-realimag.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/match-realimag.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-forwprop-details" } */ + +/* __real complex (__real x) = x */ +double realimag_1(double x) +{ + _Complex double t1 = x; + double realimag_1_val = __real t1; + return realimag_1_val; +} +/* { dg-final { scan-tree-dump "gimple_match_and_simplified to realimag_1_val_\\d\+ = x_\\d\+\\(D\\)" "forwprop1" } } */ + +/* { dg-final { cleanup-tree-dump "forwprop2" } } */