From: Gary Thomas <gthomas@redhat.com>
To: Grant Edwards <grante@visi.com>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] arm-elf-gcc question
Date: Sat, 11 Nov 2000 05:08:00 -0000 [thread overview]
Message-ID: <XFMail.20001111060821.gthomas@redhat.com> (raw)
In-Reply-To: <20001110172831.A15647@visi.com>
This is definitely a C compiler issue. I'd suggest that you
take it to them (gcc@gcc.gnu.org) if you want to pursue it.
On 10-Nov-2000 Grant Edwards wrote:
> On Fri, Nov 10, 2000 at 03:47:28PM -0700, Gary Thomas wrote:
>
>> On 10-Nov-2000 Grant Edwards wrote:
>> > This is really a gcc question, but I figure this is the list
>> > with the most people using the same version I am. ;)
>> >
>> > Do other people with the arm-elf-gcc 2.95.2 with ecos patches
>> > get this sort of incredibly odd-looking code, or is mine
>> > broken?
>> >
>> > [I've only written two compilers in my life, neither of which
>> > was anything to brag about, but... yikes!]
>>
>> This basically a jump table representing your switch statement.
>> The compiler makes choices about how to implement such a statement
>> and in this case, it was decided that a table of addresses indexed
>> by the "case" selector (i.e. a jump table) was the fastest/cheapest
>> way to go.
>>
>> What did you want/expect instead?
>
> I dunno. Something more like what you get if you write it as
> an equivalent if/else. I thought it was pretty standard for
> compilers to figure out whether a switch() was better
> represented by sequential tests or by a jump table. For a
> sparsely populated "case space" compilers I've used in the past
> have generally swtiched to sequential compares to save space.
> Even with size optimization turned on (-Os), it generates the
> jumptable version which is 5X larger than sequential compares.
>
> Memory is cheap, but it's never cheap enough. ;)
>
> If the size of the case space is increased slightly (from 0x20
> to 0x28) gcc does switch to sequential compares.
>
> The threshold could probably be lower -- especially on the ARM.
> The ARM better at comparing for multiple values than many other
> CPUs. You can test for any of 8 const values in 8 instructions
> (best case):
>
> cmp r3, #1
> cmpne r3, #2
> [...]
> cmpne r3, #8
>
> While on other CPUs it takes roughly twice as many instructions.
>
> --
> Grant Edwards
> grante@visi.com
prev parent reply other threads:[~2000-11-11 5:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-10 14:39 Grant Edwards
2000-11-10 14:47 ` Gary Thomas
2000-11-10 15:26 ` Grant Edwards
2000-11-11 5:08 ` Gary Thomas [this message]
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=XFMail.20001111060821.gthomas@redhat.com \
--to=gthomas@redhat.com \
--cc=ecos-discuss@sources.redhat.com \
--cc=grante@visi.com \
/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).