Andy wrote:but it generates other unnecessary instructions - are there any plans to fix this?
Yes, we hope to improve the C compiler's code generation for 64bit operations in the next release.
Really what I'd like to know is if it can be done without doing extra shifts/masks to split the long long int.
Don't worry about leaving the shifts in, they should be optimised away. The following example:
Code: Select all
long long maccs(long long sum, int x, int y)
{
unsigned sum_lo = (unsigned)sum;
int sum_hi = (int)(sum >> 32);
unsigned result_lo;
int result_hi;
asm("maccs %1, %0, %4, %5" :
"=r"(result_lo), "=r"(result_hi) :
"0"(sum_lo), "1"(sum_hi), "r"(x), "r"(y));
return result_lo | ((long long)result_hi << 32);
}
Compiles to (9.9.2 tools):
Code: Select all
maccs:
maccs r1, r0, r2, r3
retsp 0