#402 More efficient comparisons for stm8

None
closed-fixed
None
5
2014-04-12
2013-08-30
No

Some comparisons, e.g. x > 255 can be done by by looking at the upper bytes only (e.g. do an x>= 2) on the upper byte. The stm8 port should do this, when it provides an advantage (e.g. stack operand, register a free).

Philipp

Related

Feature Requests: #402

Discussion

  • Ben Shi

    Ben Shi - 2014-03-24

    unsinged int > 255 <===> upper byte != 0
    unsinged int <= 255 <===> upper byte == 0
    signed char / int / long < 0 <===> sign bit is set
    signed char / int / long >= 0 <===> sign bit is unset
    unsinged long > 65535 <===> (bit 23 - 16) != 0 || (bit 31 - 24) != 0
    unsinged long <= 65535 <===> (bit 23 - 16) == 0 && (bit 31 - 24) == 0

    any more special cases ?

     
  • Philipp Klaus Krause

    One could try to make it a bit more general, e.g.:

    unsinged int / unsigned long /unsigned long long > 255 <===> upper byte(s) != 0

    and so on.

    Philipp

     
  • Philipp Klaus Krause

    We also should be careful to only do it where it provides an advantage: E.g. testing xh separately might be more expensive than just testing all of x. Similar when we have a stack operand, and x is free, but not a.

    Philipp

     
    • Ben Shi

      Ben Shi - 2014-03-25

      Yes. All cases (in A / in X / in Y / on stack) can utilize the TNZ / TNZW instruction.

      it is sure to save size and cycles via directly tnz on op.

      在2014年03月24 16时24分,"Philipp Klaus Krause"spth@users.sf.net写道:

      We also should be careful to only do it where it provides an advantage: E.g. testing xh separately might be more expensive than just testing all of x. Similar when we have a stack operand, and x is free, but not a.

      Philipp


      [feature-requests:#402] More efficient comparisons for stm8

      Status: open
      Group:
      Created: Fri Aug 30, 2013 01:13 PM UTC by Philipp Klaus Krause
      Last Updated: Mon Mar 24, 2014 08:22 AM UTC
      Owner: nobody

      Some comparisons, e.g. x > 255 can be done by by looking at the upper bytes only (e.g. do an x>= 2) on the upper byte. The stm8 port should do this, when it provides an advantage (e.g. stack operand, register a free).

      Philipp


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/sdcc/feature-requests/402/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Feature Requests: #402

  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
    • Group: -->
     
  • Philipp Klaus Krause

    Implemented in revision #8988.

    Philipp

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks