[PATCH] strchr broken on SPU with non 16byte aligned argument - take 2
Jeff Johnston
jjohnstn@redhat.com
Mon Dec 4 05:56:00 GMT 2006
Patch applied.
-- Jeff J.
Kazunori Asayama wrote:
> Kazunori Asayama <asayama@sm.sony.co.jp> wrote:
>> Andrew_Pinski@playstation.sony.com wrote:
>>> I noticed that the GCC testcase gcc.c-torture/execute/string-opt-5.c
>>> is failing on the spu and was debugging it and it looks like strchr does
>>> not handle correctly a non 16byte aligned agrument.
>>> Here is the reduced testcase which is failing:
>> Here is a patch to fix the problem.
>> But I'm worried that there may be similar problem to it...
>
> I investigated all other string functions in libc/machine/spu, and I
> found the same problem in strrchr().
>
> Here is a patch to fix these problems. Please apply this instead of
> the previous one.
>
> Thanks,
>
> 2006-12-01 Kazunori Asayama <asayama@sm.sony.co.jp>
>
> * libc/machine/spu/strchr.c: Fix mask for misaligned string.
> * libc/machine/spu/strrchr.c: Ditto.
>
> Index: newlib/newlib/libc/machine/spu/strchr.c
> ===================================================================
> --- newlib.orig/newlib/libc/machine/spu/strchr.c
> +++ newlib/newlib/libc/machine/spu/strchr.c
> @@ -44,7 +44,7 @@ char *strchr(const char *s, int c)
> vec_uint4 cmp_c, cmp_0;
> vec_uint4 result;
> vec_uint4 mask;
> - vec_uint4 one = spu_splats((unsigned int)-1);
> + vec_uint4 one = spu_splats(0xffffU);
> /* Scan memory array a quadword at a time. Skip leading
> * mis-aligned bytes.
> */
> Index: newlib/newlib/libc/machine/spu/strrchr.c
> ===================================================================
> --- newlib.orig/newlib/libc/machine/spu/strrchr.c
> +++ newlib/newlib/libc/machine/spu/strrchr.c
> @@ -45,7 +45,7 @@ char * strrchr(const char *s, int c)
> vec_uint4 cmp_c, cmp_0, cmp;
> vec_uint4 res_ptr, res_cmp;
> vec_uint4 mask, result;
> - vec_uint4 one = spu_splats((unsigned int)-1);
> + vec_uint4 one = spu_splats(0xffffU);
> /* Scan memory array a quadword at a time. Skip leading
> * mis-aligned bytes.
> */
More information about the Newlib
mailing list