However, in looking at it, if we rewrite the code to have come from
comparisons:
<snip>
_Bool bfoo_cmp (long w, long x, long y, long z)
{
_Bool a = (w < x);
_Bool b = (y < z);
_Bool r = ~a & b;
return r;
}
We get:
<snip>
.L.bfoo_cmp:
cmpd 6,3,4
cmpd 7,5,6
mfcr 3,2
rlwinm 3,3,25,1
mfcr 6,1
rlwinm 6,6,29,1
andc 3,6,3
blr
It is a bit better on 32-bit:
bfoo_cmp:
cmpw 7,3,4
cmpw 6,5,6
mfcr 3
rlwinm 6,3,25,1
rlwinm 3,3,29,1
andc 3,6,3
blr
And it would have been nice to use the logcal comparison operations
in the CR
register unit (i.e. doing a crandc in the CR unit rather than
moving the value
from a CR to a GPR -- cmpd/mfcr/rlwinm instructions).
We cannot avoid an mfcr then, either. It would be one machine
instruction shorter though (but can be more expensive to execute,
on some CPUs).
That you get two MFCRs on 64-bit is a target bug.
Segher