On 07/25/2012 12:15 PM, Jon Beniston wrote: > For MIPS and LM32, truncation is performed in the calling function > and sign extension in the called function. One of these operations > seems redundant. For ARM, truncation is performed in the caller, > but sign-extension isn't performed in the callee, which seems more > efficient. Why might this be?
This is defined by the system ABI, which specifies when zero- or sign- extension get done. The ARM ABI explicitly requires a caller to extend types appropriately before they are passed, and a callee can depend on that. We in GCC have to follow the rules, and we can take advantage of them. I suspect the answer to your question will be found in the ABIs of the MIPS and LM32, but I'm not familiar with either of those. Andrew.