Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#411 Eliminate cast before jump

None
closed-fixed
None
5
2014-09-24
2014-05-08
No

For the following example code

#include <stdbool.h>

unsigned char c;

void g(void)
{
    if((bool)(c % 2))
        g();
}

the cast to bool results in inefficient generated code. sdcc should optimize out a cast to bool when the result is used as a jump condition only. While the above example is artifical, similar code is often generated when inlining functions that return bool.

Philipp

Discussion

    • summary: Eliminate cast to bool before jump --> Eliminate cast before jump
    • Group: -->
     
  • More casts than just those to bool could be eliminated: If we had e.g. a cast to long instead of bool, we could eliminate that one as well.

    Philipp

     
    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
     
  • Implemented in revision #9080.

    Philipp