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

            Bug ID: 79963
           Summary: vec_eq_any extracts wrong CR bit when compiling with
                    -mcpu=power9
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acsawdey at gcc dot gnu.org
                CC: meissner at gcc dot gnu.org, wschmidt at gcc dot gnu.org
  Target Milestone: ---
            Target: powerpc64*-*-* power9

Tested with trunk 245979:

gcc/xgcc -Bgcc ../trunk/gcc/testsuite/gcc.target/powerpc/altivec-12.c -maltivec
-lm -g -o ./altivec-12.exe

In test testsuite/gcc.target/powerpc/altivec-12.c line 50:

   CHECK_IF (vec_any_eq (h, addf1));

For power9 we generate this code:

.L17:
        .loc 1 50 0 is_stmt 1
        addis 9,2,.LC1@toc@ha
        ld 9,.LC1@toc@l(9)
        lxv 12,0(9)
        addis 9,2,addf1@toc@ha
        addi 9,9,addf1@toc@l
        lxv 0,0(9)
        xvcmpeqsp. 0,12,0
        mfcr 9,2
        rlwinm 9,9,25,1
        xori 9,9,0x1
        extsw 9,9
        cmpdi 7,9,0
        bne 7,.L18
        .loc 1 50 0 is_stmt 0 discriminator 1
        bl abort

In gdb I can see that h and addf1 are equal after loading, and the comparison
is correct, however we are extracting the wrong bit from the cr with the
rlwinm.

For power8 we generate this code:

.L17:
        .loc 1 50 0 is_stmt 1
        addis 9,2,.LC1@toc@ha
        ld 9,.LC1@toc@l(9)
        lxvd2x 0,0,9
        xxpermdi 12,0,0,2
        addis 9,2,addf1@toc@ha
        addi 9,9,addf1@toc@l
        lxvd2x 0,0,9
        xxpermdi 0,0,0,2
        xvcmpeqsp. 0,12,0
        mfcr 9,2
        rlwinm 9,9,27,1
        xori 9,9,0x1
        extsw 9,9
        cmpdi 7,9,0
        bne 7,.L18
        .loc 1 50 0 is_stmt 0 discriminator 1
        bl abort

which runs correctly.

Reply via email to