<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Optimizing gcc to use lr / r14 in leaf functions...?</title><link>https://community.arm.com/developer/tools-software/tools/f/armds-forum/524/optimizing-gcc-to-use-lr-r14-in-leaf-functions</link><description> Note: This was originally posted on 5th November 2009 at http://forums.arm.com Hi everyone, I&amp;#39;m having difficulty convincing gcc to use r14 when cross-compiling C code for my most critical leaf function - arguably the oldest ARM hand-coding trick in</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Optimizing gcc to use lr / r14 in leaf functions...?</title><link>https://community.arm.com/thread/1120?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:56:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f0b88912-1e6d-40c8-becd-580492b5071e</guid><dc:creator>Nick Pelling</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 12th November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Thanks for that, much appreciated!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I&amp;#39;ll go hunting for whatever gcc patch between 4.2.1 and 4.3.2 caused r14 to fall out of favour...&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizing gcc to use lr / r14 in leaf functions...?</title><link>https://community.arm.com/thread/1118?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:56:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:63267da0-2674-4889-b68f-f4085d600e6e</guid><dc:creator>Simon Craske</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 12th November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Nick,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I&amp;#39;ve compared 4.2.1 and 4.3.2; 4.2.1 does use LR as an iterator in the example code I provided (even with -mtune=arm926ej-s); 4.3.2 always appears to be using stack space rather than LR.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;hth&lt;/span&gt;&lt;br /&gt;&lt;span&gt;s.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizing gcc to use lr / r14 in leaf functions...?</title><link>https://community.arm.com/thread/1119?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:56:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f10771f2-d0b1-4aca-a883-6bbf5ad9b405</guid><dc:creator>Nick Pelling</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 11th November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;If you compile that same code under gcc4.4.1 with -O3 -mtune=arm926ej-s , it doesn&amp;#39;t use r14 at all!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Can I please ask you to compile it under 4.2.1 with -mtune=arm926ej-s? That should show up where the key difference lies.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Thanks, ....Nick Pelling....&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;PS: I hacked in a bit of intrinsic inline assembler to make use of r14 (saving and restoring it outside the inner loop, of course), but was mysteriously unable to get the (very simple) code to work on the target machine. This makes me suspect that some curious r14-related behaviour may be at play on the arm926ej-s...&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizing gcc to use lr / r14 in leaf functions...?</title><link>https://community.arm.com/thread/1116?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:56:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9a993d04-eb4e-4c88-852e-d45435245aa1</guid><dc:creator>Simon Craske</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 6th November 2009 at &lt;a href="http://forums.arm.com"&gt;http://forums.arm.com&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Are you sure it&amp;#39;s not just a feature of the code you&amp;#39;re giving it? The following [admittedly contrived] code will use LR as one of the loop iterators when compiled with gcc4.2.1, but only with -O3 :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;int foo(int r0) {&lt;br /&gt; int r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14;&lt;br /&gt;&lt;br /&gt; r1 = 0;&lt;br /&gt;&lt;br /&gt; for(r2=0;r2&amp;lt;r0;r2++)&lt;br /&gt; for(r3=0;r3&amp;lt;r0;r3++)&lt;br /&gt; for(r4=0;r4&amp;lt;r0;r4++)&lt;br /&gt; for(r5=0;r5&amp;lt;r0;r5++)&lt;br /&gt; for(r6=0;r6&amp;lt;r0;r6++)&lt;br /&gt; for(r7=0;r7&amp;lt;r0;r7++)&lt;br /&gt; for(r8=0;r8&amp;lt;r0;r8++)&lt;br /&gt; for(r9=0;r9&amp;lt;r0;r9++)&lt;br /&gt; for(r10=0;r10&amp;lt;r0;r10++)&lt;br /&gt; for(r11=0;r11&amp;lt;r0;r11++)&lt;br /&gt; for(r12=0;r12&amp;lt;r0;r12++)&lt;br /&gt; for(r13=0;r13&amp;lt;r0;r13++)&lt;br /&gt; for(r14=0;r14&amp;lt;r0;r14++)&lt;br /&gt;&amp;#160; r1++;&lt;br /&gt;&lt;br /&gt; return r1;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;hth&lt;/span&gt;&lt;br /&gt;&lt;span&gt;s.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>