From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81088 invoked by alias); 20 Oct 2015 12:06:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 81077 invoked by uid 89); 20 Oct 2015 12:06:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f172.google.com Received: from mail-yk0-f172.google.com (HELO mail-yk0-f172.google.com) (209.85.160.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 20 Oct 2015 12:06:43 +0000 Received: by yknn9 with SMTP id n9so13869920ykn.0 for ; Tue, 20 Oct 2015 05:06:41 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.49.211 with SMTP id x202mr2047296ywx.147.1445342801021; Tue, 20 Oct 2015 05:06:41 -0700 (PDT) Received: by 10.37.117.136 with HTTP; Tue, 20 Oct 2015 05:06:40 -0700 (PDT) In-Reply-To: References: Date: Tue, 20 Oct 2015 12:13:00 -0000 Message-ID: Subject: Re: Move some bit and binary optimizations in simplify and match From: Richard Biener To: "Hurugalawadi, Naveen" Cc: Marc Glisse , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg01868.txt.bz2 On Tue, Oct 20, 2015 at 8:46 AM, Hurugalawadi, Naveen wrote: > Hi, > >>> +/* Fold X + (X / CST) * -CST to X % CST. */ >>> This one is still wrong > Removed. > >>> I don't understand the point of the FLOAT_TYPE_P check. > The check was there in fold-const. So, just had the same check. > >>> Will we also simplify (A & B) - (A & ~B) into B - (A ^ B) ? > Done. > >>> or maybe integer_all_onesp (const_binop (BIT_XOR_EXPR, type, @2, @1)) > Done. > >>> :c on bit_ior? It should also allow you to merge the 2 CST versions into one. > Had it. But due to the error on "logical_inverted_value"; confused it with > this pattern and had duplicated it. > >>> I am not really in favor of the indentation change (or the comment). > Done. > >>> This patch is ok when bootstrapped / tested and with a proper changelog entry. > Regression tested on X86_64 with no extra failures. +(simplify + (minus (bit_and:s @0 INTEGER_CST@2) (bit_and:s @0 INTEGER_CST@1)) + (if (integer_all_onesp (const_binop (BIT_XOR_EXPR, type, @2, @1))) + (minus (bit_xor @0 @1) @1))) use if (wi::bit_and (@2, @1) == 0) and instead of the 2nd group +/* Fold (A & B) - (A & ~B) into B - (A ^ B). */ +(simplify + (minus (bit_and:s @0 @1) (bit_and:s @0 (bit_not @1))) + (minus @1 (bit_xor @0 @1))) +(simplify + (minus (bit_and:s @0 INTEGER_CST@1) (bit_and:s @0 INTEGER_CST@2)) + (if (integer_all_onesp (const_binop (BIT_XOR_EXPR, type, @2, @1))) + (minus @1 (bit_xor @0 @1)))) place a :c on the minus of the one not matching INTEGER_CSTs. +(simplify + (bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1)) + (if (integer_all_onesp (const_binop (BIT_XOR_EXPR, type, @2, @1))) + (bit_xor @0 @1))) see above, use wi::bit_and instead Otherwise looks ok to me. RIchard. > 2015-10-20 Richard Biener > Naveen H.S > > * fold-const.c (fold_binary_loc) : Move (-A) * (-B) -> A * B > to match.pd. > Move (a * (1 << b)) is (a << b) to match.pd. > Move convert (C1/X)*C2 into (C1*C2)/X to match.pd. > Move ~X & X, (X == 0) & X, and !X & X are zero to match.pd. > Move X & ~X , X & (X == 0), and X & !X are zero to match.pd. > > * match.pd (mult:c @0 (convert? (lshift integer_onep@1 @2))): > New simplifier. > (mult (rdiv:s REAL_CST@0 @1) REAL_CST@2): New simplifier. > (bit_and:c (convert? @0) (convert? (bit_not @0))): New simplifier. > (bit_ior (bit_and:s @0 (bit_not:s @1)) (bit_and:s (bit_not:s @0) @1)) > : New simplifier. > (mult:c (convert1? (negate @0)) (convert2? negate_expr_p@1)): > New simplifier. > (match (logical_inverted_value @0) (truth_not @0)) : New Predicate. > > > > 2015-10-20 Richard Biener > Naveen H.S > > * fold-const.c (fold_binary_loc) : Move Fold (A & ~B) - (A & B) > into (A ^ B) - B to match.pd > Move (X & ~Y) | (~X & Y) is X ^ Y to match.pd. > > * match.pd (minus (bit_and:s @0 (bit_not @1)) (bit_and:s @0 @1)): > New simplifier. > (minus (bit_and:s @0 INTEGER_CST@2) (bit_and:s @0 INTEGER_CST@1)): > New simplifier. > (minus (bit_and:s @0 @1) (bit_and:s @0 (bit_not @1))): New simplifier. > (minus (bit_and:s @0 INTEGER_CST@1) (bit_and:s @0 INTEGER_CST@2)): > New simplifier. > (bit_ior:c (bit_and:c @0 (bit_not @1)) (bit_and:c (bit_not @0) @1)): > New simplifier. > (bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1)): > New simplifier.