From 4420675c9d361643d1179ad67e0bb35c8fbdd1ce Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 17 Apr 2011 22:03:53 -0400 Subject: Fix POWER4/POWER7 optimized strncmp to not read past differing bytes --- sysdeps/powerpc/powerpc64/power4/strncmp.S | 11 ++++++----- sysdeps/powerpc/powerpc64/power7/strncmp.S | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'sysdeps/powerpc/powerpc64') diff --git a/sysdeps/powerpc/powerpc64/power4/strncmp.S b/sysdeps/powerpc/powerpc64/power4/strncmp.S index 7a1665d2bc..94ae85b9e4 100644 --- a/sysdeps/powerpc/powerpc64/power4/strncmp.S +++ b/sysdeps/powerpc/powerpc64/power4/strncmp.S @@ -1,5 +1,5 @@ /* Optimized strcmp implementation for PowerPC64. - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2011 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 @@ -143,30 +143,31 @@ L(u1): bdz L(u4) cmpd rWORD1, rWORD2 beq- cr1, L(u4) + bne- L(u4) lbzu rWORD3, 1(rSTR1) lbzu rWORD4, 1(rSTR2) - bne- L(u4) cmpdi cr1, rWORD3, 0 bdz L(u3) cmpd rWORD3, rWORD4 beq- cr1, L(u3) + bne- L(u3) lbzu rWORD1, 1(rSTR1) lbzu rWORD2, 1(rSTR2) - bne- L(u3) cmpdi cr1, rWORD1, 0 bdz L(u4) cmpd rWORD1, rWORD2 beq- cr1, L(u4) + bne- L(u4) lbzu rWORD3, 1(rSTR1) lbzu rWORD4, 1(rSTR2) - bne- L(u4) cmpdi cr1, rWORD3, 0 bdz L(u3) cmpd rWORD3, rWORD4 beq- cr1, L(u3) + bne- L(u3) lbzu rWORD1, 1(rSTR1) lbzu rWORD2, 1(rSTR2) - beq+ L(u1) + b L(u1) L(u3): sub rRTN, rWORD3, rWORD4 blr diff --git a/sysdeps/powerpc/powerpc64/power7/strncmp.S b/sysdeps/powerpc/powerpc64/power7/strncmp.S index 34f1e52df9..5ee5e2eafa 100644 --- a/sysdeps/powerpc/powerpc64/power7/strncmp.S +++ b/sysdeps/powerpc/powerpc64/power7/strncmp.S @@ -1,5 +1,5 @@ /* Optimized strcmp implementation for POWER7/PowerPC64. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010, 2011 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 @@ -145,30 +145,31 @@ L(u1): bdz L(u4) cmpd rWORD1,rWORD2 beq cr1,L(u4) + bne L(u4) lbzu rWORD3,1(rSTR1) lbzu rWORD4,1(rSTR2) - bne L(u4) cmpdi cr1,rWORD3,0 bdz L(u3) cmpd rWORD3,rWORD4 beq cr1,L(u3) + bne L(u3) lbzu rWORD1,1(rSTR1) lbzu rWORD2,1(rSTR2) - bne L(u3) cmpdi cr1,rWORD1,0 bdz L(u4) cmpd rWORD1,rWORD2 beq cr1,L(u4) + bne L(u4) lbzu rWORD3,1(rSTR1) lbzu rWORD4,1(rSTR2) - bne L(u4) cmpdi cr1,rWORD3,0 bdz L(u3) cmpd rWORD3,rWORD4 beq cr1,L(u3) + bne L(u3) lbzu rWORD1,1(rSTR1) lbzu rWORD2,1(rSTR2) - beq L(u1) + b L(u1) L(u3): sub rRTN,rWORD3,rWORD4 blr -- cgit 1.4.1