From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13283 invoked by alias); 23 Aug 2011 09:37:06 -0000 Received: (qmail 13273 invoked by uid 22791); 23 Aug 2011 09:37:05 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Aug 2011 09:36:42 +0000 Received: (qmail 22523 invoked from network); 23 Aug 2011 09:36:40 -0000 Received: from unknown (HELO ?84.152.222.249?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Aug 2011 09:36:40 -0000 Message-ID: <4E53744B.6040502@codesourcery.com> Date: Tue, 23 Aug 2011 10:08:00 -0000 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110801 Lightning/1.0b3pre Thunderbird/3.1.11 MIME-Version: 1.0 To: Jakub Jelinek CC: Eric Botcazou , Richard Sandiford , Richard Henderson , GCC Patches Subject: Re: Add __builtin_clrsb, similar to clz/ctz References: <4DF9FA9A.8040505@codesourcery.com> <4DFA2E85.2030601@redhat.com> <4DFFA1AE.7070405@codesourcery.com> <20110823090549.GC2687@tyan-ft48-01.lab.bos.redhat.com> In-Reply-To: <20110823090549.GC2687@tyan-ft48-01.lab.bos.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/msg01855.txt.bz2 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. > >> * simplify-rtx.c (simplify_const_unary_operation): Likewise. >> Use op_mode rather than mode when optimizing ffs, clz, ctz, parity >> and 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))). This > is supposed to yield 64, but with your changes > it yields 128 - the op_mode here is VOIDmode, This is what shouldn't happen. > 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