Patchwork Disable dlmzb on the PowerPC 405 due to the AMCC 405EP

login
register
mail settings
Submitter Herwig, Björn
Date Nov. 9, 2012, 1:33 p.m.
Message ID <48D3D52125C49B43AE880038E2E5314BCC2927@SRV101.gdsys.de>
Download mbox | patch
Permalink /patch/198063/
State Rejected
Headers show

Comments

Herwig, Björn - Nov. 9, 2012, 1:33 p.m.
It is generally assumed, that all PowerPC 405 cores support the dlmzb instruction.
Sadly, the AMCC 405EP core is an exception to that rule. And while this must be known
to the Linux kernel people, GCC and GLIBC default to use dlmzb on all 405s.

This adds a patch to crosstool-ng, which removes the optimized assembler
implementations using dlmzb from eglibc-ports-2_16 and also killing memset.S
due to an already known problem with cache sizes on the 405, which also affects
the 405EP [1].

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=14595

The second patch added modifies GCC 4.7.2 to never emit dlmzb for all 405s.

With these two patches in place, it is possible to use GCC 4.7.2 and EGLIBC 2.16
for a perfectly running Linux rootfs on the AMCC 405EP.

Signed-off-by: Bjoern A. Herwig <herwig@gdsys.de>






--
For unsubscribe information see http://sourceware.org/lists.html#faq
Yann E. MORIN - Nov. 9, 2012, 2:50 p.m.
Björn, All,

On Friday 09 November 2012 Herwig, Björn wrote:
> It is generally assumed, that all PowerPC 405 cores support the dlmzb instruction.
> Sadly, the AMCC 405EP core is an exception to that rule. And while this must be known
> to the Linux kernel people, GCC and GLIBC default to use dlmzb on all 405s.
> 
> This adds a patch to crosstool-ng, which removes the optimized assembler
> implementations using dlmzb from eglibc-ports-2_16 and also killing memset.S
> due to an already known problem with cache sizes on the 405, which also affects
> the 405EP [1].
> 
> [1] http://sourceware.org/bugzilla/show_bug.cgi?id=14595
> 
> The second patch added modifies GCC 4.7.2 to never emit dlmzb for all 405s.
> 
> With these two patches in place, it is possible to use GCC 4.7.2 and EGLIBC 2.16
> for a perfectly running Linux rootfs on the AMCC 405EP.

These patches are too intrusive to be added to crosstool-NG. It should be
fixed upstream (ie. eglibc/glib and gcc) instead.

Regards,
Yann E. MORIN.

Patch

diff -r 340bad0ab841 patches/eglibc/ports-2_16/004-remove-405-dlmzb.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/eglibc/ports-2_16/004-remove-405-dlmzb.patch	Fri Nov 09 14:06:27 2012 +0100
@@ -0,0 +1,626 @@ 
+diff -urN eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/memset.S eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/memset.S
+--- eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/memset.S	2012-03-10 02:14:00.000000000 +0100
++++ eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/memset.S	1970-01-01 01:00:00.000000000 +0100
+@@ -1,154 +0,0 @@
+-/* Optimized memset implementation for PowerPC476.
+-   Copyright (C) 2010 Free Software Foundation, Inc.
+-   This file is part of the GNU C Library.
+-
+-   The GNU C Library is free software; you can redistribute it and/or
+-   modify it under the terms of the GNU Lesser General Public
+-   License as published by the Free Software Foundation; either
+-   version 2.1 of the License, or (at your option) any later version.
+-
+-   The GNU C Library is distributed in the hope that it will be useful,
+-   but WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-   Lesser General Public License for more details.
+-
+-   You should have received a copy of the GNU Lesser General Public
+-   License along with the GNU C Library.  If not, see
+-   <http://www.gnu.org/licenses/>.  */
+-
+-#include <sysdep.h>
+-#include <bp-sym.h>
+-#include <bp-asm.h>
+-
+-/* memset
+-
+-       r3:destination address and return address
+-       r4:source integer to copy
+-       r5:byte count
+-       r11:sources integer to copy in all 32 bits of reg
+-       r12:temp return address
+-
+-       Save return address in r12
+-       If destinationn is unaligned and count is greater tha 255 bytes
+-       set 0-3 bytes to make destination aligned
+-       If count is greater tha 255 bytes and setting zero to memory
+-       use dbcz to set memeory when we can
+-       otherwsie do the follwoing
+-       If 16 or more words to set we use 16 word copy loop.
+-       Finaly we set 0-15 extra bytes with string store. */
+-
+-EALIGN (BP_SYM (memset), 5, 0)
+-       rlwinm  r11,r4,0,24,31
+-       rlwimi  r11,r4,8,16,23
+-       rlwimi  r11,r11,16,0,15
+-       addi    r12,r3,0
+-       cmpwi   r5,0x00FF
+-       ble     L(preword8_count_loop)
+-       cmpwi   r4,0x00
+-       beq     L(use_dcbz)
+-       neg     r6,r3
+-       clrlwi. r6,r6,30
+-       beq     L(preword8_count_loop)
+-       addi    r8,0,1
+-       mtctr   r6
+-       subi    r3,r3,1
+-
+-L(unaligned_bytecopy_loop):
+-       stbu    r11,0x1(r3)
+-       subf.   r5,r8,r5
+-       beq     L(end_memset)
+-       bdnz    L(unaligned_bytecopy_loop)
+-       addi    r3,r3,1
+-
+-L(preword8_count_loop):
+-       srwi.   r6,r5,4
+-       beq     L(preword2_count_loop)
+-       mtctr   r6
+-       addi    r3,r3,-4
+-       mr      r8,r11
+-       mr      r9,r11
+-       mr      r10,r11
+-
+-L(word8_count_loop_no_dcbt):
+-       stwu    r8,4(r3)
+-       stwu    r9,4(r3)
+-       subi    r5,r5,0x10
+-       stwu    r10,4(r3)
+-       stwu    r11,4(r3)
+-       bdnz    L(word8_count_loop_no_dcbt)
+-       addi    r3,r3,4
+-
+-L(preword2_count_loop):
+-       clrlwi. r7,r5,28
+-       beq     L(end_memset)
+-       mr      r8,r11
+-       mr      r9,r11
+-       mr      r10,r11
+-       mtxer   r7
+-       stswx   r8,0,r3
+-
+-L(end_memset):
+-       addi    r3,r12,0
+-       blr
+-
+-L(use_dcbz):
+-       neg     r6,r3
+-       clrlwi. r7,r6,28
+-       beq     L(skip_string_loop)
+-       mr      r8,r11
+-       mr      r9,r11
+-       mr      r10,r11
+-       subf    r5,r7,r5
+-       mtxer   r7
+-       stswx   r8,0,r3
+-       add     r3,r3,r7
+-
+-L(skip_string_loop):
+-       clrlwi  r8,r6,25
+-       srwi.   r8,r8,4
+-       beq     L(dcbz_pre_loop)
+-       mtctr   r8
+-
+-L(word_loop):
+-       stw     r11,0(r3)
+-       subi    r5,r5,0x10
+-       stw     r11,4(r3)
+-       stw     r11,8(r3)
+-       stw     r11,12(r3)
+-       addi    r3,r3,0x10
+-       bdnz    L(word_loop)
+-
+-L(dcbz_pre_loop):
+-       srwi    r6,r5,7
+-       mtctr   r6
+-       addi    r7,0,0
+-
+-L(dcbz_loop):
+-       dcbz    r3,r7
+-       addi    r3,r3,0x80
+-       subi    r5,r5,0x80
+-       bdnz    L(dcbz_loop)
+-       srwi.   r6,r5,4
+-       beq     L(postword2_count_loop)
+-       mtctr   r6
+-
+-L(postword8_count_loop):
+-       stw     r11,0(r3)
+-       subi    r5,r5,0x10
+-       stw     r11,4(r3)
+-       stw     r11,8(r3)
+-       stw     r11,12(r3)
+-       addi    r3,r3,0x10
+-       bdnz    L(postword8_count_loop)
+-
+-L(postword2_count_loop):
+-       clrlwi. r7,r5,28
+-       beq     L(end_memset)
+-       mr      r8,r11
+-       mr      r9,r11
+-       mr      r10,r11
+-       mtxer   r7
+-       stswx   r8,0,r3
+-       b       L(end_memset)
+-END (BP_SYM (memset))
+-libc_hidden_builtin_def (memset)
+diff -urN eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strcmp.S eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strcmp.S
+--- eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strcmp.S	2012-03-10 02:14:00.000000000 +0100
++++ eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strcmp.S	1970-01-01 01:00:00.000000000 +0100
+@@ -1,136 +0,0 @@
+-/* Optimized strcmp implementation for PowerPC476.
+-   Copyright (C) 2010 Free Software Foundation, Inc.
+-   This file is part of the GNU C Library.
+-
+-   The GNU C Library is free software; you can redistribute it and/or
+-   modify it under the terms of the GNU Lesser General Public
+-   License as published by the Free Software Foundation; either
+-   version 2.1 of the License, or (at your option) any later version.
+-
+-   The GNU C Library is distributed in the hope that it will be useful,
+-   but WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-   Lesser General Public License for more details.
+-
+-   You should have received a copy of the GNU Lesser General Public
+-   License along with the GNU C Library.  If not, see
+-   <http://www.gnu.org/licenses/>.  */
+-
+-#include <sysdep.h>
+-#include <bp-sym.h>
+-#include <bp-asm.h>
+-
+-/* strcmp
+-
+-       Register Use
+-       r0:temp return equality
+-       r3:source1 address, return equality
+-       r4:source2 address
+-
+-       Implementation description
+-       Check 2 words from src1 and src2. If unequal jump to end and
+-       return src1 > src2 or src1 < src2.
+-       If null check bytes before null and then jump to end and
+-       return src1 > src2, src1 < src2 or src1 = src2.
+-       If src1 = src2 and no null, repeat. */
+-
+-EALIGN (BP_SYM(strcmp),5,0)
+-       neg     r7,r3
+-       clrlwi  r7,r7,20
+-       neg     r8,r4
+-       clrlwi  r8,r8,20
+-       srwi.   r7,r7,5
+-       beq     L(byte_loop)
+-       srwi.   r8,r8,5
+-       beq     L(byte_loop)
+-       cmplw   r7,r8
+-       mtctr   r7
+-       ble     L(big_loop)
+-       mtctr   r8
+-
+-L(big_loop):
+-       lwz     r5,0(r3)
+-       lwz     r6,4(r3)
+-       lwz     r8,0(r4)
+-       lwz     r9,4(r4)
+-       dlmzb.  r12,r5,r6
+-       bne     L(end_check)
+-       cmplw   r5,r8
+-       bne     L(st1)
+-       cmplw   r6,r9
+-       bne     L(st1)
+-       lwz     r5,8(r3)
+-       lwz     r6,12(r3)
+-       lwz     r8,8(r4)
+-       lwz     r9,12(r4)
+-       dlmzb.  r12,r5,r6
+-       bne     L(end_check)
+-       cmplw   r5,r8
+-       bne     L(st1)
+-       cmplw   r6,r9
+-       bne     L(st1)
+-       lwz     r5,16(r3)
+-       lwz     r6,20(r3)
+-       lwz     r8,16(r4)
+-       lwz     r9,20(r4)
+-       dlmzb.  r12,r5,r6
+-       bne     L(end_check)
+-       cmplw   r5,r8
+-       bne     L(st1)
+-       cmplw   r6,r9
+-       bne     L(st1)
+-       lwz     r5,24(r3)
+-       lwz     r6,28(r3)
+-       addi    r3,r3,0x20
+-       lwz     r8,24(r4)
+-       lwz     r9,28(r4)
+-       addi    r4,r4,0x20
+-       dlmzb.  r12,r5,r6
+-       bne     L(end_check)
+-       cmplw   r5,r8
+-       bne     L(st1)
+-       cmplw   r6,r9
+-       bne     L(st1)
+-       bdnz    L(big_loop)
+-       b       L(byte_loop)
+-
+-L(end_check):
+-       subfic  r12,r12,4
+-       blt     L(end_check2)
+-       rlwinm  r12,r12,3,0,31
+-       srw     r5,r5,r12
+-       srw     r8,r8,r12
+-       cmplw   r5,r8
+-       bne     L(st1)
+-       b       L(end_strcmp)
+-
+-L(end_check2):
+-       addi    r12,r12,4
+-       cmplw   r5,r8
+-       rlwinm  r12,r12,3,0,31
+-       bne     L(st1)
+-       srw     r6,r6,r12
+-       srw     r9,r9,r12
+-       cmplw   r6,r9
+-       bne     L(st1)
+-
+-L(end_strcmp):
+-       addi    r3,r0,0
+-       blr
+-
+-L(st1):
+-       mfcr    r3
+-       blr
+-
+-L(byte_loop):
+-       lbz     r5,0(r3)
+-       addi    r3,r3,1
+-       lbz     r6,0(r4)
+-       addi    r4,r4,1
+-       cmplw   r5,r6
+-       bne     L(st1)
+-       cmpwi   r5,0
+-       beq     L(end_strcmp)
+-       b       L(byte_loop)
+-END (BP_SYM (strcmp))
+-libc_hidden_builtin_def (strcmp)
+diff -urN eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strcpy.S eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strcpy.S
+--- eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strcpy.S	2012-03-10 02:14:00.000000000 +0100
++++ eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strcpy.S	1970-01-01 01:00:00.000000000 +0100
+@@ -1,109 +0,0 @@
+-/* Optimized strcpy implementation for PowerPC476.
+-   Copyright (C) 2010 Free Software Foundation, Inc.
+-   This file is part of the GNU C Library.
+-
+-   The GNU C Library is free software; you can redistribute it and/or
+-   modify it under the terms of the GNU Lesser General Public
+-   License as published by the Free Software Foundation; either
+-   version 2.1 of the License, or (at your option) any later version.
+-
+-   The GNU C Library is distributed in the hope that it will be useful,
+-   but WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-   Lesser General Public License for more details.
+-
+-   You should have received a copy of the GNU Lesser General Public
+-   License along with the GNU C Library.  If not, see
+-   <http://www.gnu.org/licenses/>.  */
+-
+-#include <sysdep.h>
+-#include <bp-sym.h>
+-#include <bp-asm.h>
+-
+-/* strcpy
+-
+-       Register Use
+-       r3:destination and return address
+-       r4:source address
+-       r10:temp destination address
+-
+-       Implementation description
+-       Loop by checking 2 words at a time, with dlmzb. Check if there is a null
+-       in the 2 words. If there is a null jump to end checking to determine
+-       where in the last 8 bytes it is. Copy the appropriate bytes of the last
+-       8 according to the null position. */
+-
+-EALIGN (BP_SYM (strcpy), 5, 0)
+-       neg     r7,r4
+-       subi    r4,r4,1
+-       clrlwi. r8,r7,29
+-       subi    r10,r3,1
+-       beq     L(pre_word8_loop)
+-       mtctr   r8
+-
+-L(loop):
+-       lbzu    r5,0x01(r4)
+-       cmpi    cr5,r5,0x0
+-       stbu    r5,0x01(r10)
+-       beq     cr5,L(end_strcpy)
+-       bdnz    L(loop)
+-
+-L(pre_word8_loop):
+-       subi    r4,r4,3
+-       subi    r10,r10,3
+-
+-L(word8_loop):
+-       lwzu    r5,0x04(r4)
+-       lwzu    r6,0x04(r4)
+-       dlmzb.  r11,r5,r6
+-       bne     L(byte_copy)
+-       stwu    r5,0x04(r10)
+-       stwu    r6,0x04(r10)
+-       lwzu    r5,0x04(r4)
+-       lwzu    r6,0x04(r4)
+-       dlmzb.  r11,r5,r6
+-       bne     L(byte_copy)
+-       stwu    r5,0x04(r10)
+-       stwu    r6,0x04(r10)
+-       lwzu    r5,0x04(r4)
+-       lwzu    r6,0x04(r4)
+-       dlmzb.  r11,r5,r6
+-       bne     L(byte_copy)
+-       stwu    r5,0x04(r10)
+-       stwu    r6,0x04(r10)
+-       lwzu    r5,0x04(r4)
+-       lwzu    r6,0x04(r4)
+-       dlmzb.  r11,r5,r6
+-       bne     L(byte_copy)
+-       stwu    r5,0x04(r10)
+-       stwu    r6,0x04(r10)
+-       b       L(word8_loop)
+-
+-L(last_bytes_copy):
+-       stwu    r5,0x04(r10)
+-       subi    r11,r11,4
+-       mtctr   r11
+-       addi    r10,r10,3
+-       subi    r4,r4,1
+-
+-L(last_bytes_copy_loop):
+-       lbzu    r5,0x01(r4)
+-       stbu    r5,0x01(r10)
+-       bdnz    L(last_bytes_copy_loop)
+-       blr
+-
+-L(byte_copy):
+-       blt     L(last_bytes_copy)
+-       mtctr   r11
+-       addi    r10,r10,3
+-       subi    r4,r4,5
+-
+-L(last_bytes_copy_loop2):
+-       lbzu    r5,0x01(r4)
+-       stbu    r5,0x01(r10)
+-       bdnz    L(last_bytes_copy_loop2)
+-
+-L(end_strcpy):
+-       blr
+-END (BP_SYM (strcpy))
+-libc_hidden_builtin_def (strcpy)
+diff -urN eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strlen.S eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strlen.S
+--- eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strlen.S	2012-03-10 02:14:00.000000000 +0100
++++ eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strlen.S	1970-01-01 01:00:00.000000000 +0100
+@@ -1,77 +0,0 @@
+-/* Optimized strlen implementation for PowerPC476.
+-   Copyright (C) 2010 Free Software Foundation, Inc.
+-   This file is part of the GNU C Library.
+-
+-   The GNU C Library is free software; you can redistribute it and/or
+-   modify it under the terms of the GNU Lesser General Public
+-   License as published by the Free Software Foundation; either
+-   version 2.1 of the License, or (at your option) any later version.
+-
+-   The GNU C Library is distributed in the hope that it will be useful,
+-   but WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-   Lesser General Public License for more details.
+-
+-   You should have received a copy of the GNU Lesser General Public
+-   License along with the GNU C Library.  If not, see
+-   <http://www.gnu.org/licenses/>.  */
+-
+-#include <sysdep.h>
+-#include <bp-sym.h>
+-#include <bp-asm.h>
+-
+-/* strlen
+-
+-       Register Use
+-       r3:source address and return length of string
+-       r4:byte counter
+-
+-       Implementation description
+-       Load 2 words at a time and count bytes, if we find null we subtract one from
+-       the count and return the count value. We need to subtract one because
+-       we don't count the null character as a byte. */
+-
+-EALIGN (BP_SYM (strlen),5,0)
+-       neg     r7,r3
+-       clrlwi. r8,r7,29
+-       addi    r4,0,0
+-       beq     L(byte_count_loop)
+-       mtctr   r8
+-
+-L(loop):
+-       lbz     r5,0(r3)
+-       cmpi    cr5,r5,0x0
+-       addi    r3,r3,0x1
+-       addi    r4,r4,0x1
+-       beq     cr5,L(end_strlen)
+-       bdnz    L(loop)
+-
+-L(byte_count_loop):
+-       lwz     r5,0(r3)
+-       lwz     r6,4(r3)
+-       dlmzb.  r12,r5,r6
+-       add     r4,r4,r12
+-       bne     L(end_strlen)
+-       lwz     r5,8(r3)
+-       lwz     r6,12(r3)
+-       dlmzb.  r12,r5,r6
+-       add     r4,r4,r12
+-       bne     L(end_strlen)
+-       lwz     r5,16(r3)
+-       lwz     r6,20(r3)
+-       dlmzb.  r12,r5,r6
+-       add     r4,r4,r12
+-       bne     L(end_strlen)
+-       lwz     r5,24(r3)
+-       lwz     r6,28(r3)
+-       addi    r3,r3,0x20
+-       dlmzb.  r12,r5,r6
+-       add     r4,r4,r12
+-       bne     L(end_strlen)
+-       b       L(byte_count_loop)
+-
+-L(end_strlen):
+-       addi    r3,r4,-1
+-       blr
+-END (BP_SYM (strlen))
+-libc_hidden_builtin_def (strlen)
+diff -urN eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strncmp.S eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strncmp.S
+--- eglibc-ports-2_16.orig/ports/sysdeps/powerpc/powerpc32/405/strncmp.S	2012-03-10 02:14:00.000000000 +0100
++++ eglibc-ports-2_16/ports/sysdeps/powerpc/powerpc32/405/strncmp.S	1970-01-01 01:00:00.000000000 +0100
+@@ -1,130 +0,0 @@
+-/* Optimized strncmp implementation for PowerPC476.
+-   Copyright (C) 2010 Free Software Foundation, Inc.
+-   This file is part of the GNU C Library.
+-
+-   The GNU C Library is free software; you can redistribute it and/or
+-   modify it under the terms of the GNU Lesser General Public
+-   License as published by the Free Software Foundation; either
+-   version 2.1 of the License, or (at your option) any later version.
+-
+-   The GNU C Library is distributed in the hope that it will be useful,
+-   but WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-   Lesser General Public License for more details.
+-
+-   You should have received a copy of the GNU Lesser General Public
+-   License along with the GNU C Library.  If not, see
+-   <http://www.gnu.org/licenses/>.  */
+-
+-#include <sysdep.h>
+-#include <bp-sym.h>
+-#include <bp-asm.h>
+-
+-/* strncmp
+-
+-       Register Use
+-       r0:temp return equality
+-       r3:source1 address, return equality
+-       r4:source2 address
+-       r5:byte count
+-
+-       Implementation description
+-       Touch in 3 lines of D-cache.
+-       If source1 or source2 is unaligned copy 0-3 bytes to make source1 aligned
+-       Check 2 words from src1 and src2. If unequal jump to end and
+-       return src1 > src2 or src1 < src2.
+-       If null check bytes before null and then jump to end and
+-       return src1 > src2, src1 < src2 or src1 = src2.
+-       If count = zero check bytes before zero counter and then jump to end and
+-       return src1 > src2, src1 < src2 or src1 = src2.
+-       If src1 = src2 and no null, repeat. */
+-
+-EALIGN (BP_SYM(strncmp),5,0)
+-       neg     r7,r3
+-       clrlwi  r7,r7,20
+-       neg     r8,r4
+-       clrlwi  r8,r8,20
+-       srwi.   r7,r7,3
+-       beq     L(prebyte_count_loop)
+-       srwi.   r8,r8,3
+-       beq     L(prebyte_count_loop)
+-       cmplw   r7,r8
+-       mtctr   r7
+-       ble     L(preword2_count_loop)
+-       mtctr   r8
+-
+-L(preword2_count_loop):
+-       srwi.   r6,r5,3
+-       beq     L(prebyte_count_loop)
+-       mfctr   r7
+-       cmplw   r6,r7
+-       bgt     L(set_count_loop)
+-       mtctr   r6
+-       clrlwi  r5,r5,29
+-
+-L(word2_count_loop):
+-       lwz     r10,0(r3)
+-       lwz     r6,4(r3)
+-       addi    r3,r3,0x08
+-       lwz     r8,0(r4)
+-       lwz     r9,4(r4)
+-       addi    r4,r4,0x08
+-       dlmzb.  r12,r10,r6
+-       bne     L(end_check)
+-       cmplw   r10,r8
+-       bne     L(st1)
+-       cmplw   r6,r9
+-       bne     L(st1)
+-       bdnz    L(word2_count_loop)
+-
+-L(prebyte_count_loop):
+-       addi    r5,r5,1
+-       mtctr   r5
+-       bdz     L(end_strncmp)
+-
+-L(byte_count_loop):
+-       lbz     r6,0(r3)
+-       addi    r3,r3,1
+-       lbz     r7,0(r4)
+-       addi    r4,r4,1
+-       cmplw   r6,r7
+-       bne     L(st1)
+-       cmpwi   r6,0
+-       beq     L(end_strncmp)
+-       bdnz    L(byte_count_loop)
+-       b       L(end_strncmp)
+-
+-L(set_count_loop):
+-       slwi    r7,r7,3
+-       subf    r5,r7,r5
+-       b       L(word2_count_loop)
+-
+-L(end_check):
+-       subfic  r12,r12,4
+-       blt     L(end_check2)
+-       rlwinm  r12,r12,3,0,31
+-       srw     r10,r10,r12
+-       srw     r8,r8,r12
+-       cmplw   r10,r8
+-       bne     L(st1)
+-       b       L(end_strncmp)
+-
+-L(end_check2):
+-       addi    r12,r12,4
+-       cmplw   r10,r8
+-       rlwinm  r12,r12,3,0,31
+-       bne     L(st1)
+-       srw     r6,r6,r12
+-       srw     r9,r9,r12
+-       cmplw   r6,r9
+-       bne     L(st1)
+-
+-L(end_strncmp):
+-       addi    r3,r0,0
+-       blr
+-
+-L(st1):
+-       mfcr    r3
+-       blr
+-END (BP_SYM (strncmp))
+-libc_hidden_builtin_def (strncmp)
diff -r 340bad0ab841 patches/gcc/4.7.2/000-default-ppc405-nodlmzb.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/gcc/4.7.2/000-default-ppc405-nodlmzb.patch	Fri Nov 09 14:06:27 2012 +0100
@@ -0,0 +1,12 @@ 
+diff -urN gcc-4.7.2.orig/gcc/config/rs6000/rs6000-cpus.def gcc-4.7.2/gcc/config/rs6000/rs6000-cpus.def
+--- gcc-4.7.2.orig/gcc/config/rs6000/rs6000-cpus.def	2011-05-10 16:46:34.000000000 +0200
++++ gcc-4.7.2/gcc/config/rs6000/rs6000-cpus.def	2012-11-09 11:32:35.559102631 +0100
+@@ -38,7 +38,7 @@
+ RS6000_CPU ("403", PROCESSOR_PPC403,
+ 	    POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_STRICT_ALIGN)
+ RS6000_CPU ("405", PROCESSOR_PPC405,
+-	    POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW | MASK_DLMZB)
++	    POWERPC_BASE_MASK | MASK_SOFT_FLOAT | MASK_MULHW)
+ RS6000_CPU ("405fp", PROCESSOR_PPC405,
+ 	    POWERPC_BASE_MASK | MASK_MULHW | MASK_DLMZB)
+ RS6000_CPU ("440", PROCESSOR_PPC440,