This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
builtin_str{,n}cmp bug on s390{,x}
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 10 Jul 2003 17:53:16 +0200
- Subject: builtin_str{,n}cmp bug on s390{,x}
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Following testcase crashes on s390.
The problem is that s390 cmpstrsi insn
clc 0(17,%r1),0(%r2)
in the testcase below) does not behave like IA-32 rep; cmpsb.
The former has memcmp behaviour, the latter strcmp behaviour.
This means we can use cmpstrsi insn on s390 only for memcmp
builtin and not strcmp/strncmp builtins.
Now, my question is what do you prefer:
a) introduce cmpmemsi etc. insns which builtin memcmp would use
if they were not defined, it would fall back to cmpstrsi
(cmpstrM would have strncmp semantics while cmpmemM would
have memcmp semantics)
b) add some target macro which would tell what semantics cmpstrM
has
c) kill cmpstrM on s390*
#include <sys/mman.h>
#include <stdlib.h>
void test (const char *p)
{
if (__builtin_strncmp (p, "abcdefghijklmnopq", 17) == 0)
abort ();
}
int main (void)
{
char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (p == MAP_FAILED)
return 0;
if (munmap (p + 65536, 65536) < 0)
return 0;
__builtin_memcpy (p + 65536 - 5, "abcd", 5);
test (p + 65536 - 5);
return 0;
}
Jakub