C语言编译器优化问题
函数中包含一个汇编jmp语句时,编译器不再进行优化,如下面的fun1函数,如果将return换成jmp,编译器生成的代码质量就会非常差,没有任何的优化。
由于应用特殊,函数fun1不能被直接调用,而进入时只能通过指令跳转方式,退出时也需要使用跳转,请问其中的C语言代码能有什么方法使编译器编译时对其优化吗?
int t, next, rr;
void fun1(void)
{
int tmp = t * 2;
t = tmp +1;
next = rr;
return ;//__asm jmp next;
}
int _tmain(int argc, _TCHAR* argv[])
{
t = 1;
__asm mov rr, offset ext;
next = (int) fun1;
__asm jmp next;
ext:
printf("%d\n",t);
return 0;//这个小程序只是用来说明问题的例子
}