Missing S12Z compiler intrinsics for max/min

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Missing S12Z compiler intrinsics for max/min

ソリューションへジャンプ
1,692件の閲覧回数
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,612件の閲覧回数
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,612件の閲覧回数
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,612件の閲覧回数
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,613件の閲覧回数
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