Keil Logo

Register Variable

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
Christian Gradl
Posted
12-Feb-2019 09:57 GMT
Toolset
ARM
New! Register Variable

hi
i want to migrate from arm compiler 5 to 6

compiler 5 uses for following local variable a register (e.g. r0) register unsigned long len;

compiler 6 does not
why?
which keyword should i use therefore

Author
Andrew Neil
Posted
12-Feb-2019 10:21 GMT
Toolset
ARM
New! Why does this matter to you?

A compiler's use of processor registers is an entirely internal matter of the specific implementation.

Why does this matter to you?

If it really does matter, then you should probably be writing in assembler - not a high-level language.

Author
Christian Gradl
Posted
12-Feb-2019 11:25 GMT
Toolset
ARM
New! RE: Why does this matter to you?

Hi
not a really good answer!
it is a matter of speed (variables in stackmem or in registers).

How can i force the c compiler 6 to use a register variables?
Normally with the keyword "register" but the compiler 6 ignores this.

Author
Andrew Neil
Posted
12-Feb-2019 12:04 GMT
Toolset
None
New! RE: How can i force the c compiler 6 to use a register variables?

You can't!

As stated in the language specification, the 'register' keyword is merely a hint - the compiler is in no way obliged to take any notice of it.

Again, if you really need to do this kind of micro-optimisation, then you should be writing in assembler.

Have you looked at the optimisation settings provided by the compiler ?

Author
Andrew Neil
Posted
12-Feb-2019 12:13 GMT
Toolset
ARM
New! RE: Have you looked at the optimisation settings provided by the compiler ?


http://www.keil.com/support/man/docs/armclang_ref/

http://www.keil.com/support/man/docs/armclang_mig/armclang_mig_Chunk745110769.htm

Author
Christian Gradl
Posted
12-Feb-2019 12:39 GMT
Toolset
ARM
New! RE: Have you looked at the optimisation settings provided by the compiler ?

Hi
thanx for the answer
My problem is, that the support for compiler 5 will end in 2020. So for new projects i have to migrate to compiler 6.
But the new compiler 6 creates a lot of inefficient code and the size of my image inreases from 530kb to 890kb (compiling with -O0 with C5 and C6)

Example: d = (unsigned long*)&Image$$ARM_LIB_STACK$$ZI$$Base; len = STACKSIZE >> 2; while (len--) *d++ = 0xCCCCCCCC;

C6 makes
ER_CODE:80002C0A MOV R0, #0x2001C000
ER_CODE:80002C12 STR R0, [SP,#0xC+var_8]
ER_CODE:80002C14 MOV R0, #0x4000
ER_CODE:80002C1C LSRS R0, R0, #2
ER_CODE:80002C1E STR R0, [SP,#0xC+var_C]
ER_CODE:80002C20 B loc_80002C22
ER_CODE:80002C22 loc_80002C22
ER_CODE:80002C22 LDR R0, [SP,#0xC+var_C]
ER_CODE:80002C24 SUBS R1, R0, #1
ER_CODE:80002C26 STR R1, [SP,#0xC+var_C]
ER_CODE:80002C28 CMP R0, #0
ER_CODE:80002C2A BEQ loc_80002C3C
ER_CODE:80002C2C B loc_80002C2E
ER_CODE:80002C2E loc_80002C2E
ER_CODE:80002C2E LDR R0, [SP,#0xC+var_8]
ER_CODE:80002C30 ADDS R1, R0, #4
ER_CODE:80002C32 STR R1, [SP,#0xC+var_8]
ER_CODE:80002C34 MOV.W R1, #0xCCCCCCCC
ER_CODE:80002C38 STR R1, [R0]
ER_CODE:80002C3A B loc_80002C22
ER_CODE:80002C3C loc_80002C3C

C5
ER_CODE:80002B9E LDR d, =unk_2001C000
ER_CODE:80002BA0 LDR R2, =0x4000
ER_CODE:80002BA2 LSRS len, R2, #2
ER_CODE:80002BA4 B loc_80002BAC
ER_CODE:80002BA6 loc_80002BA6
ER_CODE:80002BA6 MOV.W R2, #0xCCCCCCCC
ER_CODE:80002BAA STMIA d!, {R2}
ER_CODE:80002BAC loc_80002BAC
ER_CODE:80002BAC SUBS R2, len, #0
ER_CODE:80002BAE SUB.W len, len, #1
ER_CODE:80002BB2 BNE loc_80002BA6
ER_CODE:80002BB4 BX LR

The thing is register variables increases speed and the image size gets smaller.

Now what can i do?
*) C6 makes everything going slower
*) C5 with no further support

Using C6 with optimization is not an alternative, my source is already optimized programmed and optimization makes other known problems

Author
Andrew Neil
Posted
12-Feb-2019 12:46 GMT
Toolset
None
New! RE: optimization makes other known problems

That is almost certainly due to problems in your source code.

"my source is already optimized"

You can't really optimise a HLL at the source level - certainly not to the point of dictating specific register usage.

If you've tried to do stuff like that at the HLL source lever, it is quite likely counter-productive

You should write the HLL source to be clear & maintainable, and let the compiler do the optimisation.

Author
Christian Gradl
Posted
12-Feb-2019 13:08 GMT
Toolset
None
New! RE: optimization makes other known problems

hi
no more comments, you are definite wrong in that case.
my code is optimized, i think you first should read some articles about programming...

the fact is C6 creates inefficient code in comparsion to C5.

Author
Tamir Michael
Posted
12-Feb-2019 13:29 GMT
Toolset
None
New! RE: optimization makes other known problems

Come on bro, enlighten us with some of your "optimized code". Arrogance and self awareness seldom go hand in hand !

Author
Hans-Bernhard Broeker
Posted
12-Feb-2019 21:00 GMT
Toolset
ARM
New! RE: Have you looked at the optimisation settings provided by the compiler ?

compiling with -O0

Surely you're joking.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.