From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67231 invoked by alias); 12 Aug 2015 15:50:53 -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 67155 invoked by uid 89); 12 Aug 2015 15:50:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 12 Aug 2015 15:50:52 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0F36B98C36; Wed, 12 Aug 2015 15:50:50 +0000 (UTC) Received: from anchor.twiddle.net (vpn-236-145.phx2.redhat.com [10.3.236.145]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7CFon7r012567; Wed, 12 Aug 2015 11:50:49 -0400 Subject: Re: [PATCH 01/15] rs6000: Split out rs6000_is_valid_and_mask_wide To: Segher Boessenkool References: <1439341904-9345-1-git-send-email-rth@redhat.com> <1439341904-9345-2-git-send-email-rth@redhat.com> <20150812132355.GF4711@gate.crashing.org> Cc: gcc-patches@gcc.gnu.org, David Edelsohn From: Richard Henderson Message-ID: <55CB6B58.8030107@redhat.com> Date: Wed, 12 Aug 2015 15:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150812132355.GF4711@gate.crashing.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00620.txt.bz2 On 08/12/2015 06:23 AM, Segher Boessenkool wrote: > On Tue, Aug 11, 2015 at 06:11:30PM -0700, Richard Henderson wrote: >> This allows testing for a mask without having to call GEN_INT. >> >> Cc: David Edelsohn >> --- >> * config/rs6000/rs6000.c (rs6000_is_valid_mask_wide): Split out from... >> (rs6000_is_valid_mask): ... here. >> (rs6000_is_valid_and_mask_wide): Split out from... >> (rs6000_is_valid_and_mask): ... here. > > I don't like these "_wide" names much. It follows the existing practice within the backend. > You could overload the shorter > name, if you really think creating some garbage const_int's is too much > overhead (it might well be if you use it a lot more in later patches). At one stage in the development (before I became much leaner with the search for rotate), it really really mattered. >> -bool >> -rs6000_is_valid_mask (rtx mask, int *b, int *e, machine_mode mode) >> +static bool >> +rs6000_is_valid_mask_wide (unsigned HOST_WIDE_INT val, int *b, int *e, int n) > > But why change the mode parameter? The code was clearer before. So that we don't have to look up GET_MODE_BITSIZE (mode). >> +static bool >> +rs6000_is_valid_and_mask_wide (unsigned HOST_WIDE_INT val, machine_mode mode) >> { >> int nb, ne; >> >> - if (!rs6000_is_valid_mask (mask, &nb, &ne, mode)) >> - return false; >> + switch (mode) >> + { >> + case DImode: >> + if (!rs6000_is_valid_mask_wide (val, &nb, &ne, 64)) >> + return false; >> + /* For DImode, we need a rldicl, rldicr, or a rlwinm with >> + mask that does not wrap. */ >> + return (ne == 0 || nb == 63 || (nb < 32 && ne <= nb)); >> >> - /* For DImode, we need a rldicl, rldicr, or a rlwinm with mask that >> - does not wrap. */ >> - if (mode == DImode) >> - return (ne == 0 || nb == 63 || (nb < 32 && ne <= nb)); >> + case SImode: >> + if (!rs6000_is_valid_mask_wide (val, &nb, &ne, 32)) >> + return false; >> + /* For SImode, rlwinm can do everything. */ >> + return (nb < 32 && ne < 32); >> >> - /* For SImode, rlwinm can do everything. */ >> - if (mode == SImode) >> - return (nb < 32 && ne < 32); >> + default: >> + return false; >> + } >> +} >> >> - return false; > > You don't need any of these changes then, either. True, not *needed* per-se, but if you look closer I'm combining conditionals. I think the replacement here is clearer. >> /* Otherwise, fill in the lowest "hole"; if we can do the result with >> one insn, we can do the whole thing with two. */ >> - unsigned HOST_WIDE_INT val = INTVAL (c); >> + unsigned HOST_WIDE_INT val = UINTVAL (c); > > Does it matter? No. r~