<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>S32 Design Studio中的主题 Re: S32 compiler problem?different code running time with different optimization options</title>
    <link>https://community.nxp.com/t5/S32-Design-Studio/S32-compiler-problem-different-code-running-time-with-different/m-p/733660#M2252</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know which MCU you are using - MPC5744P?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway - use idle loop for timing is not good idea. There is for example PIT module for this purpose - we have example code in S32DS - pit_periodic_interrupt_mpc5744p. To your questions - please check disassembly code for your idle loop. For no optimization It looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;01002db6: se_li r7,0&lt;BR /&gt;01002db8: se_stw r7,8(r31)&lt;BR /&gt;01002dba: e_b 0x1002dc4 &amp;lt;main+140&amp;gt;&lt;BR /&gt;01002dbe: se_lwz r7,8(r31)&lt;BR /&gt;01002dc0: se_addi r7,1&lt;BR /&gt;01002dc2: se_stw r7,8(r31)&lt;BR /&gt;01002dc4: se_lwz r6,8(r31)&lt;BR /&gt;01002dc6: e_li r7,65534&lt;BR /&gt;01002dca: cmplw cr7,r6,r7&lt;BR /&gt;01002dce: mfcr r7&lt;BR /&gt;01002dd2: e_rlwinm r7,r7,28,0,3&lt;BR /&gt;01002dd6: mtcrf 128,r7&lt;BR /&gt;01002dda: e_ble 0x1002dbe &amp;lt;main+134&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which means bunch of instructions. Some optimization levels completely remove idle loop - because technically it does nothing (it is dead code).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 May 2018 12:43:05 GMT</pubDate>
    <dc:creator>jiri_kral</dc:creator>
    <dc:date>2018-05-09T12:43:05Z</dc:date>
    <item>
      <title>S32 compiler problem?different code running time with different optimization options</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/S32-compiler-problem-different-code-running-time-with-different/m-p/733659#M2251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I pulled up a pin level and set a idle loop(1200 times) &amp;nbsp;and then pull down the pin level. The pin level is measured by a scope. I found a problem of code running time which might be relevant to S32 optimation options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIU.GPDO[73].R=1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//pull up the pin 73&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for(ticker2=0;ticker2&amp;lt;1200;ticker2++)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;//idle loop for 1200 times&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIU.GPDO[73].R=0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//pull down the pin 73&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The system clock was set to 120MHz, so I thought the&amp;nbsp;high level should be longer than&amp;nbsp;10us. However, when the optimization was chosed to None(-o0) the high level time of pin73 is about 330us! &lt;SPAN&gt;And when the&amp;nbsp;optimization was chosed to Optimize(-o1) the high level time of pin73 is about 3&lt;/SPAN&gt;&lt;SPAN&gt;6&lt;/SPAN&gt;&lt;SPAN&gt;us which I think is rational.&amp;nbsp;&lt;/SPAN&gt;And when the&amp;nbsp;optimization was chosed to Optimize most(-o3) the high level time of pin73 is about 50n&lt;SPAN&gt;s which I think the idle is totally ignored by the compiler.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Question: The same code was also tested by CodeWarrior and the result is OK. So I think it might be relevant to the S32 compiler.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2018 14:24:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/S32-compiler-problem-different-code-running-time-with-different/m-p/733659#M2251</guid>
      <dc:creator>blazeblade</dc:creator>
      <dc:date>2018-05-08T14:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: S32 compiler problem?different code running time with different optimization options</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/S32-compiler-problem-different-code-running-time-with-different/m-p/733660#M2252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know which MCU you are using - MPC5744P?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway - use idle loop for timing is not good idea. There is for example PIT module for this purpose - we have example code in S32DS - pit_periodic_interrupt_mpc5744p. To your questions - please check disassembly code for your idle loop. For no optimization It looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;01002db6: se_li r7,0&lt;BR /&gt;01002db8: se_stw r7,8(r31)&lt;BR /&gt;01002dba: e_b 0x1002dc4 &amp;lt;main+140&amp;gt;&lt;BR /&gt;01002dbe: se_lwz r7,8(r31)&lt;BR /&gt;01002dc0: se_addi r7,1&lt;BR /&gt;01002dc2: se_stw r7,8(r31)&lt;BR /&gt;01002dc4: se_lwz r6,8(r31)&lt;BR /&gt;01002dc6: e_li r7,65534&lt;BR /&gt;01002dca: cmplw cr7,r6,r7&lt;BR /&gt;01002dce: mfcr r7&lt;BR /&gt;01002dd2: e_rlwinm r7,r7,28,0,3&lt;BR /&gt;01002dd6: mtcrf 128,r7&lt;BR /&gt;01002dda: e_ble 0x1002dbe &amp;lt;main+134&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which means bunch of instructions. Some optimization levels completely remove idle loop - because technically it does nothing (it is dead code).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2018 12:43:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/S32-compiler-problem-different-code-running-time-with-different/m-p/733660#M2252</guid>
      <dc:creator>jiri_kral</dc:creator>
      <dc:date>2018-05-09T12:43:05Z</dc:date>
    </item>
  </channel>
</rss>

