Missing S12Z compiler intrinsics for max/min

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Missing S12Z compiler intrinsics for max/min

跳至解决方案
1,715 次查看
kef2
Senior Contributor V

Hi,

S12Z compiler intrinsic functions are useful to optimize code without switching to assembler. But why __minu() / __mins() / __maxu() / __maxs() are missing? Optimizer seems being unable to replace something very common like this

   if(x > max) x = max;

with MINU, and time expensive conditional branch is used instead. Any plans to implement these min/max intrinsics and perhaps improve optimizer?

Thanks,

Edward

1 解答
1,635 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Edward,

Thanks for your comment.

I will escalate this as feature request to development.

Thanks for bringing the problem to our attention.

Best Regards

Jun Zhang

在原帖中查看解决方案

3 回复数
1,635 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Edward

Under CodeWarrior11 install folder, there is file MCU_S12Z_Compiler.pdf. Open this file, take a look at Chapter 17 Supported Intrinsic Functions
"When mixing high level C/C++ code with low level code for better performance, the user can either use inline assembly code or intrinsic function calls. S12Z compiler provides 14 intrinsic that can be used by the user to instruct the compiler to use a specific machine instruction."

The supported functions as as below. Other functions are not supported.

pastedImage_1.png

Thanks,

Jun Zhang

0 项奖励
回复
1,635 次查看
kef2
Senior Contributor V

Hi Jun,

yes, that was the question! Why only abs, qmul and sat are provided? __abs are very useful. __sat are quite dangerous without looking at disassembly and/or not knowing details of corresponding CPU instruction. __qmul are fine while optimizer doesn't change size of destination register. But why min/max are not here?! Min/max instruction could eliminate needless branches. I could use inline assembler, but it is not as good as it was for S12(X). Local variables on the stack or in registers are almost taboo to use with inline assembler. And __min/__max intrinsics would reduce the needs for inline assembler...

Thanks

Edward

0 项奖励
回复
1,636 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Edward,

Thanks for your comment.

I will escalate this as feature request to development.

Thanks for bringing the problem to our attention.

Best Regards

Jun Zhang