public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/29524]  New: Too much RAM used: __clz_tab[] linked
@ 2006-10-20 12:26 batt at develer dot com
  2006-10-20 14:40 ` [Bug middle-end/29524] " rguenth at gcc dot gnu dot org
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: batt at develer dot com @ 2006-10-20 12:26 UTC (permalink / raw)
  To: gcc-bugs

I noticed that the amount of RAM used, compared to the code generated by gcc
4.1.1, is increased by 256 bytes and found that this it's due to the __clz_tab
array linked in at RAM start.


-- 
           Summary: Too much RAM used: __clz_tab[] linked
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: batt at develer dot com
 GCC build triplet: 20061014
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: avr-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug middle-end/29524] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
@ 2006-10-20 14:40 ` rguenth at gcc dot gnu dot org
  2006-10-20 15:59 ` [Bug other/29524] " pinskia at gcc dot gnu dot org
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-20 14:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-10-20 14:39 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickc at redhat dot com
             Status|UNCONFIRMED                 |NEW
          Component|c                           |middle-end
     Ever Confirmed|0                           |1
  GCC build triplet|20061014                    |
   GCC host triplet|i686-pc-linux-gnu           |
   Last reconfirmed|0000-00-00 00:00:00         |2006-10-20 14:39:55
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug other/29524] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
  2006-10-20 14:40 ` [Bug middle-end/29524] " rguenth at gcc dot gnu dot org
@ 2006-10-20 15:59 ` pinskia at gcc dot gnu dot org
  2006-10-20 16:19 ` pinskia at gcc dot gnu dot org
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-20 15:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-10-20 15:58 -------
First off this should not matter as it should not be linked in as it is not
used at all.  Do you have a testcase which it links it in?


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
          Component|middle-end                  |other


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug other/29524] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
  2006-10-20 14:40 ` [Bug middle-end/29524] " rguenth at gcc dot gnu dot org
  2006-10-20 15:59 ` [Bug other/29524] " pinskia at gcc dot gnu dot org
@ 2006-10-20 16:19 ` pinskia at gcc dot gnu dot org
  2006-10-23 19:09 ` batt at develer dot com
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-20 16:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-10-20 16:19 -------
In fact this works correctly on the SPU target so I think avr is broken or you
are really using __builtin_clz.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug other/29524] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (2 preceding siblings ...)
  2006-10-20 16:19 ` pinskia at gcc dot gnu dot org
@ 2006-10-23 19:09 ` batt at develer dot com
  2006-11-07 11:10 ` batt at develer dot com
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: batt at develer dot com @ 2006-10-23 19:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from batt at develer dot com  2006-10-23 19:09 -------
I have 3 projects involving gcc and avr, and all of these have an increased RAM
usage due to __clz_tab linking after switching from gcc 4.1.1 to 4.2.
I will try as soon as possible to find a suitable testcase.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug other/29524] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (3 preceding siblings ...)
  2006-10-23 19:09 ` batt at develer dot com
@ 2006-11-07 11:10 ` batt at develer dot com
  2006-12-03 21:41 ` [Bug target/29524] [4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: batt at develer dot com @ 2006-11-07 11:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from batt at develer dot com  2006-11-07 11:10 -------
Here's the testcase:

======================================
int main(int argc, char *argv[])
{
       float O1 = argc;
       float V1 = argc+2;

       int ret = O1 * V1;
       return ret;
}
======================================

batt@murphy:~/src$ /usr/local/avr-3.4.4-install/bin/avr-gcc -Os
-Wl,-Map=bug29524.map,--cref bug29524.c && grep -P "0x0.*__clz" bug29524.map

batt@murphy:~/src$ /usr/local/avr-4.1.1-batt/bin/avr-gcc -Os
-Wl,-Map=bug29524.map,--cref bug29524.c && grep -P "0x0.*__clz" bug29524.map

batt@murphy:~/src$ /usr/local/avr-4.2-20061014-install/bin/avr-gcc -Os
-Wl,-Map=bug29524.map,--cref bug29524.c && grep -P "0x0.*__clz" bug29524.map
                0x00000434                __clzsi2
                0x00800068                __clz_tab


These are the three compilers:

batt@murphy:~/src$ /usr/local/avr-3.4.4-install/bin/avr-gcc -v
Reading specs from /usr/local/avr-3.4.4-install/bin/../lib/gcc/avr/3.4.4/specs
Configured with: ../configure --prefix=/usr/local/avr-3.4.4-install/
--target=avr --enable-languages=c,c++ --enable-multilib --with-dwarf2
--disable-libmudflap --enable-target-optspace --enable-threads=single
--with-gnu-ld --enable-install-libbfd --disable-werror --disable-gdbtk
--disable-libmudflap --disable-nls --disable-__cxa_atexit --disable-clocale
--disable-c-mbchar --disable-long-long --without-newlib
Thread model: single
gcc version 3.4.4

batt@murphy:~/src$ /usr/local/avr-4.1.1-batt/bin/avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../configure --prefix=/usr/local/avr --target=avr
--enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2 :
(reconfigured) ../configure --prefix=/usr/local/avr --target=avr --disable-nls
--disable-libssp --with-dwarf2 --enable-languages=c,c++ --no-create
--no-recursion
Thread model: single
gcc version 4.1.2 20061030 (prerelease)-batt-avr1281

batt@murphy:~/src$ /usr/local/avr-4.2-20061014-install/bin/avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../configure --prefix=/usr/local/avr --target=avr
--enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
Thread model: single
gcc version 4.2.0 20061014 (experimental)


As you can see, the clz_tab is linked in only with the SVN version of 4.2, and
it's not linked in with 4.1.1. I also used -Os (which is the compiler switch I
care about).


-- 

batt at develer dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (4 preceding siblings ...)
  2006-11-07 11:10 ` batt at develer dot com
@ 2006-12-03 21:41 ` pinskia at gcc dot gnu dot org
  2007-02-19 20:33 ` mmitchel at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-03 21:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-12-03 21:41 -------
Someone else is going to have to look into this as this works just fine on
spu-elf.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2 Regression] Too much   |[4.2/4.3 Regression] Too
                   |RAM used: __clz_tab[] linked|much RAM used: __clz_tab[]
                   |                            |linked
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (5 preceding siblings ...)
  2006-12-03 21:41 ` [Bug target/29524] [4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2007-02-19 20:33 ` mmitchel at gcc dot gnu dot org
  2007-04-02 21:47 ` giovannibajo at libero dot it
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-02-19 20:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (6 preceding siblings ...)
  2007-02-19 20:33 ` mmitchel at gcc dot gnu dot org
@ 2007-04-02 21:47 ` giovannibajo at libero dot it
  2007-05-14 21:32 ` mmitchel at gcc dot gnu dot org
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: giovannibajo at libero dot it @ 2007-04-02 21:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from giovannibajo at libero dot it  2007-04-02 22:47 -------
Anatoly, can you have a look? It's a regression in 4.2 for AVR!


-- 

giovannibajo at libero dot it changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aesok at pautinka dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (7 preceding siblings ...)
  2007-04-02 21:47 ` giovannibajo at libero dot it
@ 2007-05-14 21:32 ` mmitchel at gcc dot gnu dot org
  2007-07-23 22:57 ` eweddington at cso dot atmel dot com
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-05-14 21:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mmitchel at gcc dot gnu dot org  2007-05-14 22:28 -------
Will not be fixed in 4.2.0; retargeting at 4.2.1.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.2.0                       |4.2.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (8 preceding siblings ...)
  2007-05-14 21:32 ` mmitchel at gcc dot gnu dot org
@ 2007-07-23 22:57 ` eweddington at cso dot atmel dot com
  2007-07-23 22:58 ` eweddington at cso dot atmel dot com
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: eweddington at cso dot atmel dot com @ 2007-07-23 22:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from eweddington at cso dot atmel dot com  2007-07-23 22:57 -------
Here's what I see:

The array __clz_tab is used in a macro, count_leading_zeros, which is called in
the function __clzSI2 in libgcc2.c, which (AFAICT) gets compiled to the
function __clzsi2 and aggregated in libgcc. The __clzsi2 function is called
from the function clzusi() (in fp-bit.c) which is also included in libgcc. The
clzusi() function is called from si_to_float() and usi_to_float() (also in
fp-bit.c and included in libgcc). AFAICT, these two functions are used to
convert an int or unsigned int to float. 

The test case does exactly this type of conversion in main() in comment #5.
Testing shows that with gcc 4.2.1, and all int-to-float conversions removed,
that __clz_tab is correctly not linked into the application.

The clzusi() function was created in revision 107345, on Nov 22, 2005:
http://gcc.gnu.org/viewcvs?view=rev&revision=107345

This seems like it was an intended change. However, it is unfortunate that a
256-byte array is used in the count_leading_zeros macro. While using a table is
fast and the size is neglible on larger platforms, using up 256 bytes is very
significant on the AVR where 4K, 2K or even 1K of RAM is common. What is really
needed is an alternative implementation (non-array) that is perhaps specific to
the AVR.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (9 preceding siblings ...)
  2007-07-23 22:57 ` eweddington at cso dot atmel dot com
@ 2007-07-23 22:58 ` eweddington at cso dot atmel dot com
  2007-09-08 21:44 ` anrp at mit dot edu
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: eweddington at cso dot atmel dot com @ 2007-07-23 22:58 UTC (permalink / raw)
  To: gcc-bugs



-- 

eweddington at cso dot atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.2.1                       |4.2.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (10 preceding siblings ...)
  2007-07-23 22:58 ` eweddington at cso dot atmel dot com
@ 2007-09-08 21:44 ` anrp at mit dot edu
  2007-09-08 21:48 ` anrp at mit dot edu
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: anrp at mit dot edu @ 2007-09-08 21:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from anrp at mit dot edu  2007-09-08 21:44 -------
(In reply to comment #9)
> Here's what I see:
> 
> The array __clz_tab is used in a macro, count_leading_zeros, which is called in
> the function __clzSI2 in libgcc2.c, which (AFAICT) gets compiled to the
> function __clzsi2 and aggregated in libgcc. The __clzsi2 function is called
> from the function clzusi() (in fp-bit.c) which is also included in libgcc. The
> clzusi() function is called from si_to_float() and usi_to_float() (also in
> fp-bit.c and included in libgcc). AFAICT, these two functions are used to
> convert an int or unsigned int to float. 
> 
> The test case does exactly this type of conversion in main() in comment #5.
> Testing shows that with gcc 4.2.1, and all int-to-float conversions removed,
> that __clz_tab is correctly not linked into the application.
> 
> The clzusi() function was created in revision 107345, on Nov 22, 2005:
> http://gcc.gnu.org/viewcvs?view=rev&revision=107345
> 
> This seems like it was an intended change. However, it is unfortunate that a
> 256-byte array is used in the count_leading_zeros macro. While using a table is
> fast and the size is neglible on larger platforms, using up 256 bytes is very
> significant on the AVR where 4K, 2K or even 1K of RAM is common. What is really
> needed is an alternative implementation (non-array) that is perhaps specific to
> the AVR.

Here's an untested (I'm going to try to figure out how to get it to build into
the AVR build) function that replaces the definition of clz_tab with a 6
instruction bit of code:

; r2 in, r3 out
; r2 clobbered
; Z, C, N. V clobbered
clz_compute:
        ldi r3, 0x09           ; preload output
        clc                    ; clear C (guarentees termination with 8 loops)
clz_compute_loop1:
        rol r2                 ; push MSB into C
        dec r3                 ; dec output
        brcs clz_end           ; if C is set (msb was set), we're done
        rjmp clz_compute_loop1 ; otherwise, repeat
clz_end:


-- 

anrp at mit dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anrp at mit dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (11 preceding siblings ...)
  2007-09-08 21:44 ` anrp at mit dot edu
@ 2007-09-08 21:48 ` anrp at mit dot edu
  2007-10-09 19:30 ` mmitchel at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: anrp at mit dot edu @ 2007-09-08 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from anrp at mit dot edu  2007-09-08 21:48 -------
(In reply to comment #10)
> Here's an untested (I'm going to try to figure out how to get it to build into
> the AVR build) function that replaces the definition of clz_tab with a 6
> instruction bit of code:
> 
> ; r2 in, r3 out
> ; r2 clobbered
> ; Z, C, N. V clobbered
> clz_compute:
>         ldi r3, 0x09           ; preload output
>         clc                    ; clear C (guarentees termination with 8 loops)
> clz_compute_loop1:
>         rol r2                 ; push MSB into C
>         dec r3                 ; dec output
>         brcs clz_end           ; if C is set (msb was set), we're done
>         rjmp clz_compute_loop1 ; otherwise, repeat
> clz_end:
> 

And the first bug of the day, clc should be sec. brcs will only jump out if C
is set. On to prodding gcc...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (12 preceding siblings ...)
  2007-09-08 21:48 ` anrp at mit dot edu
@ 2007-10-09 19:30 ` mmitchel at gcc dot gnu dot org
  2007-10-24 11:16 ` wvangulik at xs4all dot nl
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-10-09 19:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from mmitchel at gcc dot gnu dot org  2007-10-09 19:22 -------
Change target milestone to 4.2.3, as 4.2.2 has been released.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.2.2                       |4.2.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (13 preceding siblings ...)
  2007-10-09 19:30 ` mmitchel at gcc dot gnu dot org
@ 2007-10-24 11:16 ` wvangulik at xs4all dot nl
  2007-11-30 14:59 ` wvangulik at xs4all dot nl
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: wvangulik at xs4all dot nl @ 2007-10-24 11:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from wvangulik at xs4all dot nl  2007-10-24 11:16 -------
(In reply to comment #10)

Something like this is smaller, faster and works for all registers (no need for
LD_regs). And could easily be writtin in to a insn:

; rOut: output register
; rIn:  input register
; rIn, Z, N are clobbered, C is set
clzqi_init:
    clr rOut           ; clear to zero
    neg rOut           ; make -1, and set C (C used for garanteed termination)
clzqi_loop1:
    inc rOut           ; inc output (C not touched)
    rol rIn            ; push MSB into C
    brcc clz_loop1     ; if C is cleared (msb was not set), continue loop
clzqi_end:

A clz on a hi/si/di would be almost the same. Extend the "rol rIn" to a rol per
sub_reg.
Of course there can be speed optimisation for hi/si/di, but for the AVR the
optimizer is in most cases set for size.
A library call to this is shorter but it may impose extra mov instruction to
fit the register constraints.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (14 preceding siblings ...)
  2007-10-24 11:16 ` wvangulik at xs4all dot nl
@ 2007-11-30 14:59 ` wvangulik at xs4all dot nl
  2007-12-22 17:15 ` j at uriah dot heep dot sax dot de
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: wvangulik at xs4all dot nl @ 2007-11-30 14:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from wvangulik at xs4all dot nl  2007-11-30 14:59 -------
Note that the use of clz for the avr is avoided by using avr-libc's math
library.
See http://lists.gnu.org/archive/html/avr-libc-dev/2007-11/msg00048.html for
more details.


-- 

wvangulik at xs4all dot nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wvangulik at xs4all dot nl


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (15 preceding siblings ...)
  2007-11-30 14:59 ` wvangulik at xs4all dot nl
@ 2007-12-22 17:15 ` j at uriah dot heep dot sax dot de
  2007-12-23 20:15 ` wvangulik at xs4all dot nl
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: j at uriah dot heep dot sax dot de @ 2007-12-22 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from j at uriah dot heep dot sax dot de  2007-12-22 17:15 -------
(In reply to comment #14)

> Note that the use of clz for the avr is avoided by using avr-libc's math
> library.

Not confirmed.  A simple test program using a floating point number:

#include <avr/io.h>
#include <math.h>

volatile float    a;

int main (void) 
{
 a=ADCH; 
}

results in 256 bytes of RAM allocation for __clz_tab[].


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (16 preceding siblings ...)
  2007-12-22 17:15 ` j at uriah dot heep dot sax dot de
@ 2007-12-23 20:15 ` wvangulik at xs4all dot nl
  2008-01-18 18:16 ` pmarques at grupopie dot com
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: wvangulik at xs4all dot nl @ 2007-12-23 20:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from wvangulik at xs4all dot nl  2007-12-23 20:15 -------
> (In reply to comment #14)
> 
> > Note that the use of clz for the avr is avoided by using avr-libc's math
> > library.
> 
> Not confirmed.  A simple test program using a floating point number:
> 

This is probably due to somne naming problems of the latest avr-libc (1.6.x)
concerning  __floatunsisf/undisf.
I tested against the 1.4.x version of the library which does not have this
problem.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (17 preceding siblings ...)
  2007-12-23 20:15 ` wvangulik at xs4all dot nl
@ 2008-01-18 18:16 ` pmarques at grupopie dot com
  2008-02-01 16:58 ` jsm28 at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: pmarques at grupopie dot com @ 2008-01-18 18:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from pmarques at grupopie dot com  2008-01-18 17:30 -------
I just found out what's causing this confusion. If you compile your program
like this:

avr-gcc -Os -mmcu=atmega168 -lm main.c -o main.elf

__clz_tab gets included. But if you compile like this:

avr-gcc -Os -mmcu=atmega168 main.c -lm -o main.elf

it doesn't!!!

So, the order you pass -lm matters to the final outcome.

Tested with gcc 4.2.2, libc 1.4.6 and libc 1.6.1.


-- 

pmarques at grupopie dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pmarques at grupopie dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (18 preceding siblings ...)
  2008-01-18 18:16 ` pmarques at grupopie dot com
@ 2008-02-01 16:58 ` jsm28 at gcc dot gnu dot org
  2008-05-19 20:47 ` [Bug target/29524] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-02-01 16:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from jsm28 at gcc dot gnu dot org  2008-02-01 16:53 -------
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.2.3                       |4.2.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.2/4.3/4.4 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (19 preceding siblings ...)
  2008-02-01 16:58 ` jsm28 at gcc dot gnu dot org
@ 2008-05-19 20:47 ` jsm28 at gcc dot gnu dot org
  2009-03-31 19:48 ` [Bug target/29524] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-05-19 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from jsm28 at gcc dot gnu dot org  2008-05-19 20:22 -------
4.2.4 is being released, changing milestones to 4.2.5.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.2.4                       |4.2.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.3/4.4/4.5 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (20 preceding siblings ...)
  2008-05-19 20:47 ` [Bug target/29524] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2009-03-31 19:48 ` jsm28 at gcc dot gnu dot org
  2009-08-04 12:39 ` rguenth at gcc dot gnu dot org
  2010-05-22 18:23 ` [Bug target/29524] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
  23 siblings, 0 replies; 25+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 19:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from jsm28 at gcc dot gnu dot org  2009-03-31 19:48 -------
Closing 4.2 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2/4.3/4.4/4.5 Regression]|[4.3/4.4/4.5 Regression] Too
                   |Too much RAM used:          |much RAM used: __clz_tab[]
                   |__clz_tab[] linked          |linked
   Target Milestone|4.2.5                       |4.3.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.3/4.4/4.5 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (21 preceding siblings ...)
  2009-03-31 19:48 ` [Bug target/29524] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-08-04 12:39 ` rguenth at gcc dot gnu dot org
  2010-05-22 18:23 ` [Bug target/29524] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #21 from rguenth at gcc dot gnu dot org  2009-08-04 12:28 -------
GCC 4.3.4 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.4                       |4.3.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug target/29524] [4.3/4.4/4.5/4.6 Regression] Too much RAM used: __clz_tab[] linked
  2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
                   ` (22 preceding siblings ...)
  2009-08-04 12:39 ` rguenth at gcc dot gnu dot org
@ 2010-05-22 18:23 ` rguenth at gcc dot gnu dot org
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 18:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #22 from rguenth at gcc dot gnu dot org  2010-05-22 18:11 -------
GCC 4.3.5 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.5                       |4.3.6


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29524


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-05-22 18:18 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-20 12:26 [Bug c/29524] New: Too much RAM used: __clz_tab[] linked batt at develer dot com
2006-10-20 14:40 ` [Bug middle-end/29524] " rguenth at gcc dot gnu dot org
2006-10-20 15:59 ` [Bug other/29524] " pinskia at gcc dot gnu dot org
2006-10-20 16:19 ` pinskia at gcc dot gnu dot org
2006-10-23 19:09 ` batt at develer dot com
2006-11-07 11:10 ` batt at develer dot com
2006-12-03 21:41 ` [Bug target/29524] [4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-02-19 20:33 ` mmitchel at gcc dot gnu dot org
2007-04-02 21:47 ` giovannibajo at libero dot it
2007-05-14 21:32 ` mmitchel at gcc dot gnu dot org
2007-07-23 22:57 ` eweddington at cso dot atmel dot com
2007-07-23 22:58 ` eweddington at cso dot atmel dot com
2007-09-08 21:44 ` anrp at mit dot edu
2007-09-08 21:48 ` anrp at mit dot edu
2007-10-09 19:30 ` mmitchel at gcc dot gnu dot org
2007-10-24 11:16 ` wvangulik at xs4all dot nl
2007-11-30 14:59 ` wvangulik at xs4all dot nl
2007-12-22 17:15 ` j at uriah dot heep dot sax dot de
2007-12-23 20:15 ` wvangulik at xs4all dot nl
2008-01-18 18:16 ` pmarques at grupopie dot com
2008-02-01 16:58 ` jsm28 at gcc dot gnu dot org
2008-05-19 20:47 ` [Bug target/29524] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2009-03-31 19:48 ` [Bug target/29524] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-08-04 12:39 ` rguenth at gcc dot gnu dot org
2010-05-22 18:23 ` [Bug target/29524] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).