UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 56355

EDK 14.5, Vivado 2013.3 - Incorrect behavior when the compiler optimization is set to –Os

Description

Using MicroBlaze MCS in ISE 14.5 there could be incorrect behavior when the compiler optimization is set to Os. 

When set to -O0 or -O2 the code seems to work correctly. 

The 14.5 compiler emits incorrect code for shift right with -Os:

 

       data >>= 16;

268:  a2400010      ori    r18, r0, 16

26c:  90830041      srl    r4, r3

270:  3252ffff      addik  r18, r18, -1

274:  be32fffc      bneid  r18, -4              // 270

278:  10842000      addk   r4, r4, r4

 

The first srl is correct, and is presumably used to handle signed/unsigned shift, but the addk is wrong.

Adding does a left-shift instead of  a right-shift.

The correct code would have been srl r4, r4

 

The same program emits correct code with the 14.6 compiler, but it is not size-optimized.

(Note that the first addk is meaningless here, and should not have been emitted at all):

 

      data >>= 16;

268:  10801800      addk   r4, r0, r3

26c:  90830041      srl    r4, r3

270:  90840041      srl    r4, r4

274:  90840041      srl    r4, r4

278:  90840041      srl    r4, r4

27c:  90840041      srl    r4, r4

280:  90840041      srl    r4, r4

284:  90840041      srl    r4, r4

288:  90840041      srl    r4, r4

28c:  90840041      srl    r4, r4

290:  90840041      srl    r4, r4

294:  90840041      srl    r4, r4

298:  90840041      srl    r4, r4

29c:  90840041      srl    r4, r4

2a0:  90840041      srl    r4, r4

2a4:  90840041      srl    r4, r4

2a8:  90840041      srl    r4, r4



Solution

This issue has been fixed in EDK 14.7 and Vivado 2013.4.

AR# 56355
Date Created 06/12/2013
Last Updated 11/20/2014
Status Active
Type General Article
Tools
  • EDK - 14.5
  • EDK - 14.6
  • Vivado Design Suite - 2013.1
  • More
  • Vivado Design Suite - 2013.2
  • Vivado Design Suite - 2013.3
  • Less