#1841 volatile iTemp

closed-fixed
None
other
4
2016-06-21
2011-09-07
No

In regression test libmullong (actually _mullong.c, which is included by libmullong), there is a volatile iTemp:
The line 723 from _mullong.c

t.l += a

is transformed into iCode

iTemp182 = t.l;
iTemp183 = a;
iTemp184 = iTemp182 + iTemp183;
t.l = iTemp184

iTemp183 is volatile, but I don't see any reason. Such unecessary volatiles can hinder optimization. I don't even see any reason an iTemp should ever be volatile.

Philipp

Discussion

  • Maarten Brock

    Maarten Brock - 2011-09-30

    The reason is that t is a union. SDCC does not know that a change to t.l also modifies t.i or t.bi. To prevent bugs SDCC makes all unions volatile internally.

     
  • Philipp Klaus Krause

    I see that it makes sense to have t.l volatile due to the shortcomings of union handling in sdcc.
    But why iTemp183? iTemp183 won't alias with anything, it could even live in registers.

    Philipp

     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
    • Category: --> other
     
  • Philipp Klaus Krause

    Fixed in revision #9629.

    Philipp

     
  • Ben Shi

    Ben Shi - 2016-06-20

    close it?

     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     

Log in to post a comment.