From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117953 invoked by alias); 11 Jun 2015 15:25:36 -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 117875 invoked by uid 89); 11 Jun 2015 15:25:35 -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; Thu, 11 Jun 2015 15:25:34 +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; 11 Jun 2015 17:25:30 +0200 Received: from glisse (helo=localhost) by stedding with local-esmtp (Exim 4.85) (envelope-from ) id 1Z34ME-0004id-I6; Thu, 11 Jun 2015 17:25:30 +0200 Date: Thu, 11 Jun 2015 15:26:00 -0000 From: Marc Glisse Reply-To: gcc-patches@gcc.gnu.org To: Marek Polacek cc: GCC Patches , Richard Biener Subject: Re: match.pd: Optimize (x & y) ^ (x | y) In-Reply-To: <20150611110432.GY2756@redhat.com> Message-ID: References: <20150611110432.GY2756@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-SW-Source: 2015-06/txt/msg00853.txt.bz2 On Thu, 11 Jun 2015, Marek Polacek wrote: > I have verified this transformation on a toy testcase (tried x and y > in the range [-1000,1000]) and it does a correct thing for all integers. Note that for pure bitop (only involving &|^), testing the range [0,1] is sufficient. > +/* (x & y) ^ (x | y) -> x ^ y */ > +(simplify > + (bit_xor:c (bit_and@2 @0 @1) (bit_ior@3 @0 @1)) Make either bit_and or bit_ior commutative? Or do we canonicalize in a way that makes it unnecessary? > + (if (single_use (@2) && single_use (@3)) > + (bit_xor @0 @1))) I don't think we should use single_use here. The result is never more complicated than the original. Sure, it might increase register pressure a bit in some cases, but we have not used that as a criterion for other simplifications in match.pd yet (LLVM does though). -- Marc Glisse