From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32450 invoked by alias); 17 Jun 2011 09:24:57 -0000 Received: (qmail 32442 invoked by uid 22791); 17 Jun 2011 09:24:56 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Jun 2011 09:24:41 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by post.strato.de (klopstock mo52) (RZmta 25.18) with ESMTPA id B0058dn5H9FXjI ; Fri, 17 Jun 2011 11:20:49 +0200 (MEST) Message-ID: <4DFB1C6F.1050807@gjlay.de> Date: Fri, 17 Jun 2011 09:41:00 -0000 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: Richard Henderson CC: gcc-patches@gcc.gnu.org, Denis Chertykov , "Eric B. Weddington" , Anatoly Sokolov Subject: Re: [Patch, AVR]: PR49313, fix PR29524 References: <4DF87FAD.4090104@gjlay.de> <4DFA55B2.4010406@redhat.com> In-Reply-To: <4DFA55B2.4010406@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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/msg01322.txt.bz2 Richard Henderson schrieb: > On 06/15/2011 02:47 AM, Georg-Johann Lay wrote: >> +#if defined (L_loop_ffsqi2) >> +;; Helper for ffshi2, ffssi2 >> +;; r25:r24 = r26 + zero_extend16 (ffs8(r24)) >> +;; r24 must be != 0 >> +;; clobbers: r26 >> +DEFUN __loop_ffsqi2 > > Why does this function have "loop" in its name? The actual > implementation is surely irrelevant. hmmm. I needed some global name that can be referenced from __ffshi2 resp. __ffssi2. The function in itself is not very helpful as stand alone. You prefer some other naming for such global helpers? >> +DEFUN __ffshi2 >> + clr r26 >> + cpse r24, __zero_reg__ >> +1: XJMP __loop_ffsqi2 >> + ldi r26, 8 >> + or r24, r25 > > It probably doesn't matter to execution speed, but why the > OR here, when you know that r24 is 0? Wouldn't the logic > be clearer spelling this with MOV? The following instruction is BRNE, a conditional branch. MOV does not modify condition code. So OR is used. Alternative would be EOR. Or MOV+TST (note that TST Rx is sugar for AND Rx,Rx). >> +#if defined (L_ctzsi2) >> +;; count trailing zeros >> +;; r25:r24 = ctz32 (r25:r22) >> +;; ctz(0) = 32 > > Note that GCC does not define ctz(0). It's explicitly undefined. > Why are you forcing a particular value here? Yes, you are right. Following patchlet ok? Johann * config/avr/libgcc.S (__ctzsi2, __ctzhi2): Map zero to 255. Index: config/avr/libgcc.S =================================================================== --- config/avr/libgcc.S (Revision 175104) +++ config/avr/libgcc.S (Arbeitskopie) @@ -977,12 +977,10 @@ ENDF __loop_ffsqi2 #if defined (L_ctzsi2) ;; count trailing zeros ;; r25:r24 = ctz32 (r25:r22) -;; ctz(0) = 32 +;; ctz(0) = 255 DEFUN __ctzsi2 XCALL __ffssi2 dec r24 - sbrc r24, 7 - ldi r24, 32 ret ENDF __ctzsi2 #endif /* defined (L_ctzsi2) */ @@ -990,12 +988,10 @@ ENDF __ctzsi2 #if defined (L_ctzhi2) ;; count trailing zeros ;; r25:r24 = ctz16 (r25:r24) -;; ctz(0) = 16 +;; ctz(0) = 255 DEFUN __ctzhi2 XCALL __ffshi2 dec r24 - sbrc r24, 7 - ldi r24, 16 ret ENDF __ctzhi2 #endif /* defined (L_ctzhi2) */ > r~