Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » SDCC
  • » [Sdcc-user] Z80 --std-c99 and _Bool results in larger code size and slow speed [RSS Feed]

#1 Dec. 7, 2010 15:19:22

Lin R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Sdcc-user] Z80 --std-c99 and _Bool results in larger code size and slow speed


Just tested rev #6078, with TestBoolean function, the compiled size are the
same now, and "_Bool" is 4ms faster than "unsigned char". Really a fast fix.
But I am still uncomfortable with "_Bool", as my overall code size is still
a little larger with "_Bool".

Woodyhttp://palmmicro.com/woody/----- Original Message -----
From: "Philipp Klaus Krause" <p***@*pth.de>
To: <sdcc-u***@*ists.sourceforge.net>
Sent: Tuesday, December 07, 2010 5:19 AM
Subject: Re: Z80 --std-c99 and _Bool results in larger code size
and slow speed


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Am 06.12.2010 20:53, schrieb Lin Rongrong:
>> Seems nobody cares about --std-c99 and _Bool speed before,
>
> Well, I do, and _Bool does get better. Naturally I use my own code for
> test cases, so if your coding style is different from mine, it's likely,
> that there's untapped potential for optimization when compiling your code.
> That's true even for things other than _Bool.
>
>> Aso I made a test
>> my self, using the following function:
>>
>> BOOLEAN TestBoolean(BOOLEAN b1)
>> {
>> USHORT s;
>> BOOLEAN b2;
>> BOOLEAN b3;
>>
>> b3 = IsHighSpeed();
>> for (s = 0; s < 30000; s ++)
>> {
>> b2 = b1 ? b3 : FALSE;
>> }
>> return b2;
>> }
>>
>> When BOOLEAN as unsigned char, the running time of this function on my
>> Z80
>> is 137ms, and code generated is less by 4 bytes.
>> When BOOLEAN as _Bool, using bit related instructions, this function need
>> 167ms to run.
>>
>> Woody
>
> Well, _Bool is still much younger, so not all potential for optimization
> has been used yet. On the other hand, unsigned char has been around for
> a very long time.
> The ternary operator ?: was not that good for _Bool, resulting in an
> unecessary cast. I just fixed it (rev #6078). From now on your example
> TestBoolean() should be faster when using _Bool compared to unsigned char.
>
> Philipp
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/>
> iEYEARECAAYFAkz9U04ACgkQbtUV+xsoLpqtuACgoYlylnNUIDShTcKuWa7eO1Ei
> 5FUAoNwdd8AlPVPqvfgAT3tKdc9HhOn1
> =JPer
> -----END PGP SIGNATURE-----
>
>
> Sdcc-user mailing list
> Sdcc-u***@*ists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/sdcc-user
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/sdcc-user

Offline

#2 Dec. 8, 2010 14:36:39

Lin R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Sdcc-user] Z80 --std-c99 and _Bool results in larger code size and slow speed


Thanks Philipp, I have decided to use _Bool from now on:http://palmmicro.com/woody/blog/ar1688/20101208.phpWoodyhttp://palmmicro.com/woody/----- Original Message -----
From: "Philipp Klaus Krause" <p***@*pth.de>
To: <sdcc-u***@*ists.sourceforge.net>
Sent: Wednesday, December 08, 2010 4:52 AM
Subject: Re: Z80 --std-c99 and _Bool results in larger code size
and slow speed


> Am 07.12.2010 16:16, schrieb Lin Rongrong:
>> Just tested rev #6078, with TestBoolean function, the compiled size are
>> the
>> same now, and "_Bool" is 4ms faster than "unsigned char".
>
> On an original Z80 _Bool should be exactly three clock cycles faster per
> loop iteration in your example. In terms of speed this is the main
> advantage of _Bool over unsigned char: saving three clock cycles each
> time we use it as a condition, be it in the ternary operator, an if/else
> or some other control mechanism.
>
>> Really a fast fix.
>> But I am still uncomfortable with "_Bool", as my overall code size is
>> still
>> a little larger with "_Bool".
>
> Well there probably are still some places where sdcc generates
> unnecessary casts for _Bool, this will improve over time (and the
> improvmeent will be faster when users report the issue on this list (as
> you did) or as a feature request (which has the advantage of not being
> forgotten as easily)).
>
> Philipp
>
>
> Sdcc-user mailing list
> Sdcc-u***@*ists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/sdcc-user
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/sdcc-user

Offline

  • Root
  • » SDCC
  • » [Sdcc-user] Z80 --std-c99 and _Bool results in larger code size and slow speed [RSS Feed]

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support