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~