x86: Tune Skylake, Cannonlake and Icelake as Haswell
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / memcmp.c
blob5489048f5f9d261f6780ca2c5ab511ad0089018c
1 /* Copyright (C) 2001 Free Software Foundation.
3 Ensure that short builtin memcmp are optimized and perform correctly.
4 On architectures with a cmpstrsi instruction, this test doesn't determine
5 which optimization is being performed, but it does check for correctness.
7 Written by Roger Sayle, 12/02/2001.
8 Additional tests by Roger Sayle after PR 3508, 12/26/2001. */
10 extern void abort (void);
11 typedef __SIZE_TYPE__ size_t;
12 extern int memcmp (const void *, const void *, size_t);
13 extern char *strcpy (char *, const char *);
14 extern void link_error (void);
16 void
17 main_test (void)
19 char str[8];
21 strcpy (str, "3141");
23 if ( memcmp (str, str+2, 0) != 0 )
24 abort ();
25 if ( memcmp (str+1, str+3, 0) != 0 )
26 abort ();
28 if ( memcmp (str+1, str+3, 1) != 0 )
29 abort ();
30 if ( memcmp (str, str+2, 1) >= 0 )
31 abort ();
32 if ( memcmp (str+2, str, 1) <= 0 )
33 abort ();
35 if (memcmp ("abcd", "efgh", 4) >= 0)
36 link_error ();
37 if (memcmp ("abcd", "abcd", 4) != 0)
38 link_error ();
39 if (memcmp ("efgh", "abcd", 4) <= 0)
40 link_error ();