https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97786

--- Comment #4 from Surya Kumari Jangala <jskumari at gcc dot gnu.org> ---
For the following test:

int test1 (double x)
{
  return __builtin_isinf_sign (x);
}

The assembly generated by trunk is:

        xststdcdp 0,1,48
        mfcr 3,128
        rlwinm 3,3,3,1
        bne 0,.L2
        mfvsrd 10,1
        li 3,1
        li 9,-1
        cmpdi 0,10,0
        isel 3,9,3,0
.L2:
        extsw 3,3
        blr

However, the sign of 'x' is stored in the CR register at bit 32. So the code
for the builtin can be optimized as follows:

        xststdcdp 0,1,48
        mfcr 4,128
        rlwinm 3,4,3,1
        bne 0,.L2
        li 9,-1
        isel 3,9,3,0    //r3 already contains 1 due to 'rlwinm'
.L2:
        extsw 3,3
        blr

Reply via email to