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
Solved! Go to Solution.
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
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.
Thanks,
Jun Zhang
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
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