#39 peepholes with labelRefCount for the mcs51 port

closed
nobody
None
5
2005-11-07
2005-02-20
No

I'd like to post this peephole here in the hope it gets some
testing prior to inclusion into SDCC.

The appended peephole file keeps track of the changes in
the reference counters for the labels. It makes use of the
new peephole keyword labelRefCountChange (SDCC 2.4.8
>961).

SDCC can thus f.e. remove an unneeded ret in the following
code:

void u( unsigned char c);
void v( unsigned char c);

void t( unsigned char c)
{
if( c ==35 )
u(65);
else
v(8);
}

Discussion

  • Frieder Ferlemann

     
    Attachments
  • Hubert Sack

    Hubert Sack - 2005-03-09

    Logged In: YES
    user_id=1160854

    I tested the new peephole file and could not find any errors.
    But my sourcecode is small and easy, so I think somemore
    testing with more complex sourcecode is recommended.

     
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    Thank you for testing. Will commit some time after 2.5.0 is out.

     
  • Hubert Sack

    Hubert Sack - 2005-03-29

    Logged In: YES
    user_id=1160854

    I added 2 more Peepholes for more effective code generated
    by the changes done by me in RFE 11 62 453

     
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    Appending the patch Hubert sent to me.

     
  • Frieder Ferlemann

    this patch is relative to 122046: peeph.def

     
    Attachments
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    this is in SDCC as of 2005-07-12 (and I should have
    remembered to close this patch then).
    Hubert, if I missed something, please resubmit.

     
  • Frieder Ferlemann

    • status: open --> closed
     
  • Hubert Sack

    Hubert Sack - 2005-11-19

    Logged In: YES
    user_id=1160854

    within the hole "PEEPH.DEF" file every conditional call
    to "labelRefCountChange" is "if" missing! The peephole is
    applied but the function is not called.
    It must be "} if labelRefCountChange(%1 -1)".
    I think this syntax should produce an error message

     
  • Hubert Sack

    Hubert Sack - 2005-11-19

    Logged In: YES
    user_id=1160854

    Because it my be misunderstood. it must be:

    .. "} if labelRefCountChange(...".

    I think the missing "if" followed by a function name should
    produce an error message.

    The peephole rule 300 (remove redundant label) should be
    a "restart" rule.

     
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    Hi Hubert,

    I added the missing ifs (in SDCC >= 1165), thanks for reporting!

    > I think the missing "if" followed by a function
    > name should produce an error message.

    Yes, would be nice to have (TM).

    > The peephole rule 300 (remove redundant label)
    > should be a "restart" rule.

    This could considerably increase compile time
    (because numerous runs over the peephole rules could be
    triggered) without the user having control over this.
    So I would not want to add this.

    Instead a parameter --num-peep-runs which should give
    similar results was discussed in the thread:
    http://sourceforge.net/mailarchive/forum.php?thread_id=8825146&forum_id=4108
    but unfortunately this also didn't spark much enthusiasm:)

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks