From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11104 invoked by alias); 16 Jun 2011 13:10:48 -0000 Received: (qmail 11083 invoked by uid 22791); 16 Jun 2011 13:10:47 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qy0-f182.google.com (HELO mail-qy0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Jun 2011 13:10:30 +0000 Received: by qyk27 with SMTP id 27so781691qyk.20 for ; Thu, 16 Jun 2011 06:10:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.48.7 with SMTP id p7mr666914qcf.249.1308229829768; Thu, 16 Jun 2011 06:10:29 -0700 (PDT) Received: by 10.229.227.204 with HTTP; Thu, 16 Jun 2011 06:10:29 -0700 (PDT) In-Reply-To: <4DF9FA9A.8040505@codesourcery.com> References: <4DF9FA9A.8040505@codesourcery.com> Date: Thu, 16 Jun 2011 13:56:00 -0000 Message-ID: Subject: Re: Add __builtin_clrsb, similar to clz/ctz From: Laurent Desnogues To: Bernd Schmidt Cc: GCC Patches Content-Type: text/plain; charset=ISO-8859-1 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-06/txt/msg01247.txt.bz2 On Thu, Jun 16, 2011 at 2:44 PM, Bernd Schmidt wrote: > Several processors have a "count redundant sign bits" instruction: > > * SIGNBITS on Blackfin > * NORM on C6X > * SBC, apparently, on picochip picoChip defines __builtin_sbc. Wouldn't that make it redundant with your __builtin_clrsb? > and probably others. For example, for a value of 0 or -1, it returns 31, > while e.g. an input 0xc0000000 produces 1. FWIW, ARM AdvSIMD has vcls. > Other compilers tend to define builtin functions called "norm" for this, > and the operation is used in some DSP benchmarks. The patch below adds a > __builtin_clrsb family of functions, similar to __builtin_clz. I'm open > to suggestions about the name; I don't particularly like "norm" but > maybe that's what users expect. I'm not sure I like clrsb. The trailing 'b' looks superfluous if you compare to clz. And clr looks too much like clear :-) Laurent