<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/html" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Ross Burton</title><link>http://www.burtonini.com/blog</link><description>A potted account of Ross' life</description><language>en</language><ttl>60</ttl><dc:creator>Ross Burton</dc:creator><admin:generatorAgent rdf:resource="http://pyblosxom.sourceforge.net/"/><admin:errorReportsTo rdf:resource="mailto:ross@burtonini.com"/><item><title>Shoddy Compilers, Part 2</title><guid isPermaLink="false">computers/crap-iar-20040510</guid><link>http://www.burtonini.com/blog/computers/crap-iar-20040510</link><description>Some may remember the original shoddy compilers post from December. This is basically more of the same. I mean, people. ...</description><content:encoded><![CDATA[  <p>
    Some may remember the original <a
    href="http://www.burtonini.com/blog/computers/crap-iar">shoddy compilers</a> post from
    December. This is basically more of the same.
  </p>
  <p>
    I mean, people.  With this code:
  </p>
  <pre>
int foo(void) {
  const int i = 42;
  return i + 3;
}</pre>
  <p>
    What compiler <em>doesn't</em> just optimise the body away to "return 45" when I ask for
    optimised code? Well, one which also doesn't optimise away the test in <tt>do {...}
    while(0)</tt>, that is the answer.
  </p>
  <p>
    This compiler has a positive plethora of optimisation options: you can optimise for either speed
    or size, from either level 0 to level 9. Set to size optimisation level 9, the generated code
    goes something like:
  </p>
  <blockquote>
Grow stack by 2 bytes<br/>
Put 42 in R16<br/>
Put 0 in R17<br/>
Store R16 via Z (stack pointer)<br/>
Store R17 via Z+<br/>
Put 45 in R16<br/>
Shrink stack by 2 bytes<br/>
Return (R16/R17 pair is the return value)
  </blockquote>
  <p>
    Nothing quite like 6 wasted instructions out of 7 on a <4MHz processor... When people moan about
    GCC not doing the right thing, they don't know the meaning of "broken compiler".  Amusingly the
    compiler didn't generate the code to clear R17 to 0, so it either noticed that had already
    happened, or the code generator is even worse than I thought.  I'm not sure what case to
    believe in.
  </p>
  <p>
    <small>NP: <cite>When It Falls</cite>, Zero 7.</small>
  </p>
]]></content:encoded><dc:date>2004-05-10T16:27:16Z</dc:date></item></channel></rss>