Given the Altivec function:

vector unsigned short peepholebug(vector unsigned short a, vector unsigned
short b) {
        vector unsigned short mask = (vector unsigned short)vec_cmplt(a, b);

        if (vec_all_ge(a, b))   return a;

        return mask;
        }

XCode 2.2.1 / gcc 4.0 on PowerMac G5 generates ( with optimizer set to -os):

mfspr r0,256
stw r0,-8(r1)
oris r0,r0,0x8000
mtspr 256,r0
vcmpgtuh. v0,v3,v2
vcmpgtuh v0,v3,v2
beq cr6,L99
vor v2,v0,v0
lwz r12,-8(r1)
mtspr 256,r12
blr

Note the second "vcmpgtuh" instruction, which is completely superfluous. The
peephole optimizer should recognize this situation and remove the instruction.
(I've filed a bug with Apple; #4519214.)


-- 
           Summary: Altivec Comparison Peephole Bug
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ben at shellandslate dot com
 GCC build triplet: 4.0.0
  GCC host triplet: 4.0.0
GCC target triplet: 4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27212

Reply via email to