AndeStar has been evolved to V3(the third generation). V3 has more better code size advantage than V2 because we design some new instructons. One example is
push25 & pop25, both are 16 bits instructions and can handle prolog and epilog while in V2 compiler has to use 32 bit instruction(
smw & lmw) to do the same work.
But push25 hasn't much transformation as smw(it is only 16 bits length), it will store at least 4 GPRs($r6,$gp,$fp,$lp) to stack. For there is a kind of sub function which only needs to save $lp as it doesn't touch other GPR at all. Now compiler in BSP400 has introduced two option "-mno-v3push/-mv3push" to let user to handle this case for different purpose.
First, let's introduce the behavior of BSP400 about the two options:
When optimazation level is "-Os", -mv3push” is implied used, compiler will default use push25 to do prolog. When set
"-mno-v3push", compiler will use smw.adw instead.
When optimazation level is other, "-mno-v3push" is implied used, compiler will default use smw.adw to do porlog, when set "-mv3push",compiler will use push25 instead.
For example we can set "-mno-v3push" in AndeSight as:
Attachment:
pic1.png [ 15.99 KiB | Viewed 15346 times ]
Compile will use smw instruction as:
Attachment:
pic2.png [ 1.35 KiB | Viewed 15346 times ]
other than
Attachment:
pic.png [ 1.3 KiB | Viewed 15346 times ]
Second, with this background, for function which is frequently called and dosen't touch any GPR we can set different optimization level for it to improve performance. The example code is:
__attribute__((optimize("O3")))
int func (… )
{
}
If there are more functions needs to set "-O3", the C code can be as:
#pragma GCC push_options
#pragma GCC optimize ("O3")
int funcA (... )
{
...
}
int funcB (... )
{
...
}
...
#pragma GCC pop_options