public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anrp at mit dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/29524] [4.2/4.3 Regression] Too much RAM used: __clz_tab[] linked
Date: Sat, 08 Sep 2007 21:44:00 -0000	[thread overview]
Message-ID: <20070908214445.20979.qmail@sourceware.org> (raw)
In-Reply-To: <bug-29524-10671@http.gcc.gnu.org/bugzilla/>



------- 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


  parent reply	other threads:[~2007-09-08 21:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-20 12:26 [Bug c/29524] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070908214445.20979.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).