From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58303 invoked by alias); 25 Jan 2017 10:49:42 -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 58286 invoked by uid 89); 25 Jan 2017 10:49:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*rguenth, inefficient, H*f:CAJOtW, H*f:sk:5kuqdGO X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Jan 2017 10:49:30 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A10A5AB5D; Wed, 25 Jan 2017 10:49:28 +0000 (UTC) Date: Wed, 25 Jan 2017 10:58:00 -0000 From: Richard Biener To: Yuri Gribov cc: GCC Patches , amodra@gmail.com, rguenth@gcc.gnu.org Subject: Re: [PATCH][PR 67328] Improve bitfield testing In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-01/txt/msg01954.txt.bz2 On Wed, 25 Jan 2017, Yuri Gribov wrote: > Hi all, > > This fixes inefficient bitfield code reported in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67328 > > Bootstrapped and regtested on x86_64. > > Ok for trunk? This isn't a regression fix and thus not appropriate at this stage. Some comments on the patch: +/* A & (2**N - 1) <= 2**K - 1 -> ~(A & (2**N - 2**K) + A & (2**N - 1) < 2**K -> ~(A & (2**N - 2**K) + A & (2**N - 1) >= 2**K -> A & (2**N - 2**K) + A & (2**N - 1) > 2**K - 1 -> A & (2**N - 2**K) + */ you miss the != 0/== 0 in the result (and the ~ is redundant then). Note that A & (2**N - 1) >= 2**K should already have been simplified to A & (2**N - 1) > 2**K - 1 (we canonicalize to smaller constants). + (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && tree_fits_uhwi_p (@2) && tree_fits_uhwi_p (@3)) + (with + { I think you should restrict this to INTEGRAL_TYPE_P types. Please use wide-ints so you do not restrict yourself to fits_uhwi_p values. Thanks, Richard.