This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: PR libc/11230: memchr overshoots on ia64
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 27 Jan 2010 22:35:48 -0800
- Subject: PATCH: PR libc/11230: memchr overshoots on ia64
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
During recovery, we shouldn't go over the last byte. This patch fixes
it.
H.J.
---
2010-01-27 H.J. Lu <hongjiu.lu@intel.com>
PR libc/11230
* sysdeps/ia64/memchr.S: Don't check beyond the last byte
during recovery.
diff --git a/sysdeps/ia64/memchr.S b/sysdeps/ia64/memchr.S
index cdd71ca..2d562f4 100644
--- a/sysdeps/ia64/memchr.S
+++ b/sysdeps/ia64/memchr.S
@@ -47,7 +47,7 @@
#define saved_lc r16
#define chr r17
#define len r18
-#define pos0 r20
+#define last r20
#define val r21
#define tmp r24
#define chrx8 r25
@@ -67,6 +67,7 @@ ENTRY(__memchr)
mov saved_pr = pr // save the predicates
.body
mov ret0 = str
+ add last = str, in2 // last byte
and tmp = 7, str // tmp = str % 8
cmp.ne p7, p0 = r0, r0 // clear p7
extr.u chr = in1, 0, 8 // chr = (unsigned char) in1
@@ -145,7 +146,9 @@ ENTRY(__memchr)
czx1.r poschr[1] = aux[1];;
cmp.ne p7, p0 = 8, poschr[1]
(p7) br.cond.spnt .foundit;;
- adds ret0 = 8, ret0 // load the next unchecked 8byte
+ adds ret0 = 8, ret0;; // load the next unchecked 8byte
+ cmp.geu p6, p0 = ret0, last // don't go over the last byte
+(p6) br.cond.spnt .notfound;;
br.sptk .l4;;
END(__memchr)