Pointless "movt r#, 0x0" instruction?

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Pointless "movt r#, 0x0" instruction?

Postby jar » Thu Dec 31, 2015 3:44 pm

I noticed GCC seems to emit the instruction pair for loading a 32-bit constant into a register (16 bits at a time). The instruction pair generally looks something like this:

Code: Select all
unsigned int foo = 0xdeadbeef;

compiles to:
Code: Select all
mov r0,0xbeef
movt r0,0xdead


If there is a compile-time constant that is 16-bits or less (just 0xbeef in the above code), GCC shouldn't need the second movt instruction for setting the upper 16-bits. It's my understanding that the single mov (immediate) instruction should be sufficient for this case because it sets all 32-bits (I'm assuming the high bits are zeroed?). GCC will still emit "movt r0, 0x0" which seems rather pointless. In some of my routines, 40% of the instructions are these instruction pairs, so the binary ends up 25% larger than needed with all the "movt r#,0x0" instructions. Compiler options like "-Os" don't seem to have any effect. Is there any way to emit tighter code short of hacking GCC? Is there some side effect of the movt instruction I don't fully understand?
User avatar
jar
 
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Re: Pointless "movt r#, 0x0" instruction?

Postby aolofsson » Thu Dec 31, 2015 4:53 pm

I recall this being a compiler performance issue that did not get resolved. Can you file an issue on the epiphany-sdk github repo? Hopefully it is an easy fix.
Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: Pointless "movt r#, 0x0" instruction?

Postby jar » Thu Dec 31, 2015 6:40 pm

Thank you, Andreas.

I submitted the issue here:
https://github.com/adapteva/epiphany-sdk/issues/61
User avatar
jar
 
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am


Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 1 guest

cron