From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25112 invoked by alias); 7 Jul 2015 06:06:38 -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 25033 invoked by uid 89); 7 Jul 2015 06:06:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,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; Tue, 07 Jul 2015 06:06:35 +0000 Received: from ip-0.net-81-220-131.standre.rev.numericable.fr (HELO laptop-mg.local) ([81.220.131.0]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Jul 2015 08:06:32 +0200 Date: Tue, 07 Jul 2015 06:06:00 -0000 From: Marc Glisse Reply-To: "gcc-patches@gcc.gnu.org" To: "Hurugalawadi, Naveen" cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PR25529] Convert (unsigned t * 2)/2 into unsigned (t & 0x7FFFFFFF) In-Reply-To: Message-ID: References: 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-07/txt/msg00442.txt.bz2 On Tue, 7 Jul 2015, Hurugalawadi, Naveen wrote: > Please find attached the patch "PR25529.patch" that converts the pattern:- > (unsigned * 2)/2 is into unsigned &0x7FFFFFFF +/* Simplify (unsigned t * 2)/2 -> unsigned t & 0x7FFFFFFF. */ +(for div (trunc_div ceil_div floor_div round_div exact_div) + (simplify + (div (mult @0 INTEGER_CST@1) INTEGER_CST@1) You don't need to repeat INTEGER_CST, the second time @1 is enough. + (with { tree n2 = build_int_cst (TREE_TYPE (@0), + wi::exact_log2 (@1)); } + (if (TYPE_UNSIGNED (TREE_TYPE (@0))) + (bit_and @0 (rshift (lshift { build_minus_one_cst (TREE_TYPE (@0)); } + { n2; }) { n2; })))))) What happens if you write t*3/3? -- Marc Glisse