From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35966 invoked by alias); 10 Nov 2015 17:44:23 -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 35954 invoked by uid 89); 10 Nov 2015 17:44:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 10 Nov 2015 17:44:21 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id tAAHiCJ5024825; Tue, 10 Nov 2015 11:44:13 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id tAAHiCbC024824; Tue, 10 Nov 2015 11:44:12 -0600 Date: Tue, 10 Nov 2015 17:44:00 -0000 From: Segher Boessenkool To: Bernd Schmidt Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com Subject: Re: [PATCH 1/2] simplify-rtx: Simplify trunc of and of shiftrt Message-ID: <20151110174411.GB23305@gate.crashing.org> References: <1d3e9ff999e20e4eb13a5825ac084074bd05a397.1447053652.git.segher@kernel.crashing.org> <5641D1F9.3090104@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5641D1F9.3090104@redhat.com> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg01256.txt.bz2 On Tue, Nov 10, 2015 at 12:16:09PM +0100, Bernd Schmidt wrote: > On 11/09/2015 08:33 AM, Segher Boessenkool wrote: > >If we have > > > > (truncate:M1 (and:M2 (lshiftrt:M2 (x:M2) C) C2)) > > > >we can write it instead as > > > > (and:M1 (lshiftrt:M1 (truncate:M1 (x:M2)) C) C2) > > > > > >+ /* Likewise (truncate:QI (and:SI (lshiftrt:SI (x:SI) C) C2)) into > >+ (and:QI (lshiftrt:QI (truncate:QI (x:SI)) C) C2) for suitable C > >+ and C2. */ > >+ if (GET_CODE (op) == AND > >+ && (GET_CODE (XEXP (op, 0)) == LSHIFTRT > >+ || GET_CODE (XEXP (op, 0)) == ASHIFTRT) > >+ && CONST_INT_P (XEXP (XEXP (op, 0), 1)) > >+ && CONST_INT_P (XEXP (op, 1)) > >+ && UINTVAL (XEXP (XEXP (op, 0), 1)) < precision > >+ && ((GET_MODE_MASK (mode) >> UINTVAL (XEXP (XEXP (op, 0), 1))) > >+ & UINTVAL (XEXP (op, 1))) > >+ == ((GET_MODE_MASK (op_mode) >> UINTVAL (XEXP (XEXP (op, 0), 1))) > >+ & UINTVAL (XEXP (op, 1)))) > > In general this would be easier to read if there were intermediate > variables called shift_amount and mask. Yes I know. All the rest of the code around is it like this though. Do you want this written in a saner way? > I'm not entirely sure what the > last condition here is supposed to test. It tests whether moving the truncate inside will give the same result. It essentially looks if it works for an x with all bits set; if that works, it works for any x. > Is it related to... > > >+ return simplify_gen_binary (AND, mode, op0, XEXP (op, 1)); > > ... the fact that here I think you'd have to trunc_int_for_mode the AND > amount for the smaller mode? Ugh yes, I still have to do that for it to be valid RTL in all cases. Thanks for catching it. Segher