From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17673 invoked by alias); 23 Aug 2011 09:49:59 -0000 Received: (qmail 17662 invoked by uid 22791); 23 Aug 2011 09:49:58 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Aug 2011 09:49:45 +0000 Received: by iyn15 with SMTP id 15so13043541iyn.34 for ; Tue, 23 Aug 2011 02:49:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.75.77 with SMTP id x13mr7446859ibj.55.1314092984325; Tue, 23 Aug 2011 02:49:44 -0700 (PDT) Received: by 10.231.50.195 with HTTP; Tue, 23 Aug 2011 02:49:44 -0700 (PDT) In-Reply-To: <4E53744B.6040502@codesourcery.com> References: <4DF9FA9A.8040505@codesourcery.com> <4DFA2E85.2030601@redhat.com> <4DFFA1AE.7070405@codesourcery.com> <20110823090549.GC2687@tyan-ft48-01.lab.bos.redhat.com> <4E53744B.6040502@codesourcery.com> Date: Tue, 23 Aug 2011 10:19:00 -0000 Message-ID: Subject: Re: Add __builtin_clrsb, similar to clz/ctz From: Richard Guenther To: Bernd Schmidt Cc: Jakub Jelinek , Eric Botcazou , Richard Sandiford , Richard Henderson , GCC Patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2011-08/txt/msg01858.txt.bz2 On Tue, Aug 23, 2011 at 11:35 AM, Bernd Schmidt w= rote: > On 08/23/11 11:05, Jakub Jelinek wrote: >> On Mon, Jun 20, 2011 at 09:38:22PM +0200, Bernd Schmidt wrote: >>> D'oh. Blackfin has a (clrsb:HI (operand:SI)) instruction, so adding this >>> showed a problem with some of the existing simplify_const_unop cases: >>> for ffs/clz/ctz/clrsb/parity/popcount, we should look at the mode of the >>> operand, rather than the mode of the operation. This limits what we can >>> do in that function, since op_mode is sometimes VOIDmode - we really >>> should add builtin folders for these at some point. >> >>> =A0 =A0 =A0* simplify-rtx.c (simplify_const_unary_operation): Likewise. >>> =A0 =A0 =A0Use op_mode rather than mode when optimizing ffs, clz, ctz, = parity >>> =A0 =A0 =A0and popcount. >> >> This change is IMHO wrong, > > Conceptually, I think it is exactly right. It may however be > inconvenient in some cases. > >> see e.g. >> PR50161 where we have (subreg:SI (popcount:DI (const_int -1))). =A0This >> is supposed to yield 64, but with your changes >> it yields 128 - the op_mode here is VOIDmode, > > This is what shouldn't happen. If it shouldn't happen, does some verifier catch it? >> cse_process_notes_1 >> perhaps could be changed for VOIDmode new_rtx to try to >> simplify_replace_rtx it... > > Is this where the problem came from? Sounds like it's worth a try. > > Wasn't Richard S. working on a patch to give constants modes? > > > Bernd > >