<?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>Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/developer/tools-software/tools/f/armds-forum/596/optimizer-removes-ssub16-used-to-set-ge-flags</link><description> Note: This was originally posted on 27th April 2009 at http://forums.arm.com I&amp;#39;m using RVCT 3.0 compiler with the optimizer (e.g., -O3). My code has inline assembly. Here&amp;#39;s my problem: If the inline assembly uses a parallel subtract instruction (e.g</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/thread/1440?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:58:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fe142a48-42af-40d4-8c14-5c02178dd1ce</guid><dc:creator>Simon Craske</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 28th April 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;nashau,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;The following pragma usage appears to generate the desired code:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;__inline int MAX16(int a1_a0, int b1_b0)&lt;br /&gt;{&lt;br /&gt;&amp;#160; int maxVal16;&lt;br /&gt;&amp;#160; __asm&amp;#160; {&lt;br /&gt; ssub16&amp;#160; maxVal16, a1_a0, b1_b0&lt;br /&gt; sel&amp;#160; maxVal16, a1_a0, b1_b0&lt;br /&gt;&amp;#160; };&lt;br /&gt;&amp;#160; return(maxVal16);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#pragma push&lt;br /&gt;#pragma O0&lt;br /&gt;int findMax(int a, int b )&lt;br /&gt;{&lt;br /&gt;&amp;#160; return (MAX16(a, b));&lt;br /&gt;}&lt;br /&gt;#pragma pop&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><item><title>RE: Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/thread/1441?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:58:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:df710b5f-7ded-4e96-88ac-573a2a1be151</guid><dc:creator>Jacob Bramley</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 28th April 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;Interesting! Looks like a compiler bug to me. Are you able to try a newer version of RVCT?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;You could work around the problem by using an embedded assembler function, rather than inline assembler, but I don&amp;#39;t think you can inline them. For example:&lt;/span&gt;&lt;br /&gt;&lt;code&gt;__asm int MAX16(int a1_a0, int b1_b0)&lt;br /&gt;{&lt;br /&gt; mov&amp;#160; r2, r0&lt;br /&gt; ssub16&amp;#160; r0, r2, r1&lt;br /&gt; sel&amp;#160; r0, r2, r1&lt;br /&gt; bx lr&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Also, GCC allows you to use the volatile keyword to indicate that an asm block should not be optimized. I&amp;#39;m not sure if RVCT provides that or not, but if it does it would solve your problem. Try doing &amp;quot;__asm volatile&amp;quot; in place of just &amp;quot;__asm&amp;quot; in your code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Jacob&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/thread/1439?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:58:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6989f574-4bf4-4a00-b2ee-cb7357f0d66f</guid><dc:creator>Peter Harris</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 28th April 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;It sounds like you could break up your single C function in to smaller pieces and only use the pragma O0 for the problematic part(s). &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;The extreme solution is to simply dump the assembler in to a separate file using fromelf, fix the optimization bug by hand, and put the result through armasm.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/thread/1438?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:58:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:427172bf-2ed7-4039-a372-9ccda506ad36</guid><dc:creator>Peter Harris</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 28th April 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;blockquote&gt;#pragma O0&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Nice - I never knew you could do that =) Learn something new every day...&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/thread/1437?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:58:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9bbfba3f-23c2-49b4-acec-424b2d8934fb</guid><dc:creator>Peter Harris</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 28th April 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;I can reproduce the issue on the latest build of RVCT 4.0, so it doesn&amp;#39;t look like a patch is available.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;You might want to raise this formally with ARM support (&lt;/span&gt;&lt;a href="mailto:support@arm.com"&gt;support@arm.com&lt;/a&gt;&lt;span&gt;) if you have a support contract for the tools.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Iso&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Optimizer removes ssub16 used to set GE flags</title><link>https://community.arm.com/thread/1436?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2013 10:58:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:389b0018-d9e8-4eb1-85b5-98a169ffac5c</guid><dc:creator>Mike Handler</dc:creator><description>&lt;div&gt;&lt;i&gt;Note: This was originally posted on 28th April 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;Sim,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Thanks for the idea of using pragma push, pragma O0, pragma pop.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Unfortunately, although the pragma&amp;#39;s were a great idea for the simplified example I gave, it doesn&amp;#39;t address my real situation.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;In reality, I have a routine with many inline asm calls and mixed with C code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;If I put the pragma&amp;#39;s surrounding the main routine per your example, I lose C-level optimization across the routine.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;If I put the pragma&amp;#39;s within the inline asm routines themselves, or surrounding the inline asm calls in the C routine, those inline asm routines mysteriously disappear from the dump file output, as if they were optimized out.&amp;#160; That is, it doesn&amp;#39;t seem like you can mix optimization levels within a routine--which seems understandable.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;So I&amp;#39;m still faced with the original problem.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Thanks again.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>