This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/10107] New: 32-bit PowerPC POWER6 memcpy uses erroneous cmpldi but should use cmplwi


The 32-bit PowerPC POWER6 memcpy uses the cmpldi insn when it should use a cmplwi.

    /* Compare the contents of register 'r5' to the value '16' where r5 */
    /* holds '12'.  */
    cmpldi      cr1,5,16

This doesn't normally prove to be a problem except when the 'length' parameter
to memcpy, held in register r5 is a computed value and the result has the high
32-bits of the register populated with junk due 64-bit operation (in the error
case a rlwinm insn),e.g.

0x1007c240 <r_gset+152>:        rlwinm  r9,r0,0,0,29
0x1007c244 <r_gset+156>:        addi    r5,r9,16
0x1007c248 <r_gset+160>:        bl      0x100dc750 <memcpy@plt>

This causes the cmpldi to result in 'greater' than when comparing '12' to '16'
which is erroneous.

The correction instruction is cmplwi which ignores the high 32-bits or 'r5':

    cmplwi      cr1,5,16

I'll supply a patch and a testcase shortly.

-- 
           Summary: 32-bit PowerPC POWER6 memcpy uses erroneous cmpldi but
                    should use cmplwi
           Product: glibc
           Version: 2.9
            Status: NEW
          Severity: normal
          Priority: P1
         Component: libc
        AssignedTo: rsa at us dot ibm dot com
        ReportedBy: rsa at us dot ibm dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: powerpc-linux
  GCC host triplet: powerpc-linux
GCC target triplet: powerpc-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=10107

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]