From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127425 invoked by alias); 8 Jun 2015 17:03:21 -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 127406 invoked by uid 89); 8 Jun 2015 17:03:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail2-relais-roc.national.inria.fr Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 08 Jun 2015 17:03:19 +0000 Received: from stedding.saclay.inria.fr (HELO stedding) ([193.55.250.194]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 08 Jun 2015 19:03:16 +0200 Received: from glisse (helo=localhost) by stedding with local-esmtp (Exim 4.85) (envelope-from ) id 1Z20SC-0007nm-09; Mon, 08 Jun 2015 19:03:16 +0200 Date: Mon, 08 Jun 2015 17:14:00 -0000 From: Marc Glisse To: Marek Polacek cc: Jakub Jelinek , GCC Patches , Richard Biener Subject: Re: [PATCH] Optimize (CST1 << A) == CST2 (PR tree-optimization/66299) In-Reply-To: <20150608151055.GR2756@redhat.com> Message-ID: References: <20150528121545.GE27320@redhat.com> <20150528123436.GM10247@tucnak.redhat.com> <20150608151055.GR2756@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-SW-Source: 2015-06/txt/msg00604.txt.bz2 On Mon, 8 Jun 2015, Marek Polacek wrote: > PR tree-optimization/66299 > * match.pd ((CST1 << A) == CST2 -> A == ctz (CST2) - ctz (CST1) > ((CST1 << A) != CST2 -> A != ctz (CST2) - ctz (CST1)): New You are braver than I am, I would have abbreviated ctz (CST2) - ctz (CST1) to CST3 in the ChangeLog ;-) > +/* (CST1 << A) == CST2 -> A == ctz (CST2) - ctz (CST1) > + (CST1 << A) != CST2 -> A != ctz (CST2) - ctz (CST1) > + if CST2 != 0. */ > +(for cmp (ne eq) > + (simplify > + (cmp (lshift INTEGER_CST@0 @1) INTEGER_CST@2) > + (with { > + unsigned int cand = wi::ctz (@2) - wi::ctz (@0); } > + (if (!integer_zerop (@2) You can probably use directly wi::ne_p (@2, 0) here. Shouldn't this be indented one space more? > + && wi::eq_p (wi::lshift (@0, cand), @2)) > + (cmp @1 { build_int_cst (TREE_TYPE (@1), cand); }))))) Making 'cand' signed, you could return 0 when cand<0, like (2<=31 for TYPE_OVERFLOW_WRAPS and false for TYPE_OVERFLOW_UNDEFINED is probably more controversial. FWIW, the patch looks good to me, thanks. -- Marc Glisse