diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2008-11-17 11:19:06 +0000 |
---|---|---|
committer | Uros Bizjak <ubizjak@gmail.com> | 2008-11-17 11:19:06 +0000 |
commit | 0c465689e60d593b5ba6f441aeab69b04429ece9 (patch) | |
tree | ec588937bd71d8c137cd8e58e26176a069ebf17b /gcc/testsuite | |
parent | b4d30c78d3880ce3f54d382962b14ac2923488d8 (diff) |
PR middle-end/37908
* optabs.c (expand_sync_operation): Properly handle NAND case
by calculating ~(t1 & val) instead of (~t1 & val).
* builtins.c (expand_builtin_sync_operation): Warn for changed
semantics in NAND builtins.
* c.opt (Wsync-nand): New warning option. Describe -Wsync-nand.
* doc/invoke.texi (Warning options): Add Wsync-nand.
* doc/extend.texi (Atomic Builtins) [__sync_fetch_and_nand]: Correct
__sync_fetch_and_nand builtin operation in the example. Add a note
about changed semantics in GCC 4.4.
[__sync_nand_and_fetch]: Correct __sync_nand_and_fetch builtin
operation in the example. Add a note about changed semantics in
GCC 4.4.
testsuite/ChangeLog:
PR middle-end/37908
* gcc.dg/pr37908.c: New test.
* gcc.dg/ia64-sync-1.c: Correct __sync_fetch_and_nand and
__sync_nand_and_fetch results. Add dg-message to look for the warning
about changed semantics of NAND builtin.
(init_si, init_di): Change init value for __sync_fetch_and_nand to -1.
(test_si, test_di): Change expected result of
__sync_nand_and_fetch to ~7.
* gcc.dg/ia64-sync-2.c: Correct __sync_fetch_and_nand and
__sync_nand_and_fetch results. Add dg-message to look for the warning
about changed semantics of NAND builtin.
(init_noret_si, init_noret_di): Change init value for
__sync_fetch_and_nand to -1.
(init_noret_si, init_noret_di): Change expected result of
__sync_nand_and_fetch to ~7.
* gcc.dg/sync-2.c: Correct __sync_fetch_and_nand and
__sync_nand_and_fetch results. Add dg-message to look for the warning
about changed semantics of NAND builtin.
(init_qi, init_qi): Change init value for __sync_fetch_and_nand to -1.
(init_hi, init_hi): Change expected result of
__sync_nand_and_fetch to ~7.
* gcc.dg/sync-3.c: Copy from sync-2.c instead of including
the c source file.
* gcc.c-torture/compile/sync-1.c: Add dg-message to look for the
warning about changed semantics of NAND builtin.
* gcc.c-torture/compile/sync-2.c: Ditto.
* gcc.c-torture/compile/sync-3.c: Ditto.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@141942 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 30 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/sync-1.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/sync-2.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/sync-3.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ia64-sync-1.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ia64-sync-2.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr37908.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/sync-2.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/sync-3.c | 102 |
9 files changed, 188 insertions, 30 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4520da37021..16c4e05e23f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,33 @@ +2008-11-17 Uros Bizjak <ubizjak@gmail.com> + + PR middle-end/37908 + * gcc.dg/pr37908.c: New test. + * gcc.dg/ia64-sync-1.c: Correct __sync_fetch_and_nand and + __sync_nand_and_fetch results. Add dg-message to look for the warning + about changed semantics of NAND builtin. + (init_si, init_di): Change init value for __sync_fetch_and_nand to -1. + (test_si, test_di): Change expected result of + __sync_nand_and_fetch to ~7. + * gcc.dg/ia64-sync-2.c: Correct __sync_fetch_and_nand and + __sync_nand_and_fetch results. Add dg-message to look for the warning + about changed semantics of NAND builtin. + (init_noret_si, init_noret_di): Change init value for + __sync_fetch_and_nand to -1. + (init_noret_si, init_noret_di): Change expected result of + __sync_nand_and_fetch to ~7. + * gcc.dg/sync-2.c: Correct __sync_fetch_and_nand and + __sync_nand_and_fetch results. Add dg-message to look for the warning + about changed semantics of NAND builtin. + (init_qi, init_qi): Change init value for __sync_fetch_and_nand to -1. + (init_hi, init_hi): Change expected result of + __sync_nand_and_fetch to ~7. + * gcc.dg/sync-3.c: Copy from sync-2.c instead of including + the c source file. + * gcc.c-torture/compile/sync-1.c: Add dg-message to look for the + warning about changed semantics of NAND builtin. + * gcc.c-torture/compile/sync-2.c: Ditto. + * gcc.c-torture/compile/sync-3.c: Ditto. + 2008-11-17 Jakub Jelinek <jakub@redhat.com> PR c++/36089 diff --git a/gcc/testsuite/gcc.c-torture/compile/sync-1.c b/gcc/testsuite/gcc.c-torture/compile/sync-1.c index 1703aaf267f..0354923d2dd 100644 --- a/gcc/testsuite/gcc.c-torture/compile/sync-1.c +++ b/gcc/testsuite/gcc.c-torture/compile/sync-1.c @@ -1,3 +1,6 @@ +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ +/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + /* Validate that each of the __sync builtins compiles. This won't necessarily link, since the target might not support the builtin, so this may result in external library calls. */ diff --git a/gcc/testsuite/gcc.c-torture/compile/sync-2.c b/gcc/testsuite/gcc.c-torture/compile/sync-2.c index 299aa09741d..bdc84ef0ae6 100644 --- a/gcc/testsuite/gcc.c-torture/compile/sync-2.c +++ b/gcc/testsuite/gcc.c-torture/compile/sync-2.c @@ -1,3 +1,5 @@ +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + /* Validate that each of the __sync builtins compiles. This won't necessarily link, since the target might not support the builtin, so this may result in external library calls. */ diff --git a/gcc/testsuite/gcc.c-torture/compile/sync-3.c b/gcc/testsuite/gcc.c-torture/compile/sync-3.c index a31c9260d96..9689eea5bb0 100644 --- a/gcc/testsuite/gcc.c-torture/compile/sync-3.c +++ b/gcc/testsuite/gcc.c-torture/compile/sync-3.c @@ -1,3 +1,5 @@ +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + /* Validate that each of the __sync builtins compiles. This won't necessarily link, since the target might not support the builtin, so this may result in external library calls. */ diff --git a/gcc/testsuite/gcc.dg/ia64-sync-1.c b/gcc/testsuite/gcc.dg/ia64-sync-1.c index efca5d7a049..83c995a624f 100644 --- a/gcc/testsuite/gcc.dg/ia64-sync-1.c +++ b/gcc/testsuite/gcc.dg/ia64-sync-1.c @@ -4,6 +4,8 @@ /* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + /* Test basic functionality of the intrinsics. The operations should not be optimized away if no one checks the return values. */ @@ -13,8 +15,8 @@ extern void abort (void); extern void *memcpy (void *, const void *, size_t); static int AI[12]; -static int init_noret_si[12] = { 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0 }; -static int test_noret_si[12] = { 1, 1, 1, 0, 1, 4, 22, -12, 7, 8, 9, 7 }; +static int init_noret_si[12] = { 0, 0, 0, 1, 0, 0, 0 , 0 , -1, 0, 0, -1 }; +static int test_noret_si[12] = { 1, 1, 1, 0, 1, 4, 22, -12, 7 , 8, 9, ~7 }; static void do_noret_si (void) @@ -35,8 +37,8 @@ do_noret_si (void) } static long AL[12]; -static long init_noret_di[12] = { 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0 }; -static long test_noret_di[12] = { 1, 1, 1, 0, 1, 4, 22, -12, 7, 8, 9, 7 }; +static long init_noret_di[12] = { 0, 0, 0, 1, 0, 0, 0 , 0 , -1, 0, 0, -1 }; +static long test_noret_di[12] = { 1, 1, 1, 0, 1, 4, 22, -12, 7 , 8, 9, ~7 }; static void do_noret_di (void) diff --git a/gcc/testsuite/gcc.dg/ia64-sync-2.c b/gcc/testsuite/gcc.dg/ia64-sync-2.c index b3ff127d9a3..69fb9b7c26e 100644 --- a/gcc/testsuite/gcc.dg/ia64-sync-2.c +++ b/gcc/testsuite/gcc.dg/ia64-sync-2.c @@ -4,6 +4,9 @@ /* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ +/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + /* Test basic functionality of the intrinsics. */ __extension__ typedef __SIZE_TYPE__ size_t; @@ -12,8 +15,8 @@ extern void abort (void); extern void *memcpy (void *, const void *, size_t); static int AI[18]; -static int init_si[18] = { 0,0,0,1,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 }; -static int test_si[18] = { 1,1,1,1,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 }; +static int init_si[18] = { 0,0,0,1,0,0, 0,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static int test_si[18] = { 1,1,1,1,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; static void do_si (void) @@ -44,7 +47,7 @@ do_si (void) abort (); if (__sync_fetch_and_xor(AI+10, 9) != 0) abort (); - if (__sync_fetch_and_nand(AI+11, 7) != 0) + if (__sync_fetch_and_nand(AI+11, 7) != -1) abort (); if (__sync_add_and_fetch(AI+12, 1) != 1) @@ -57,13 +60,13 @@ do_si (void) abort (); if (__sync_xor_and_fetch(AI+16, 9) != 9) abort (); - if (__sync_nand_and_fetch(AI+17, 7) != 7) + if (__sync_nand_and_fetch(AI+17, 7) != ~7) abort (); } static long AL[18]; -static long init_di[18] = { 0,0,0,1,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 }; -static long test_di[18] = { 1,1,1,1,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 }; +static long init_di[18] = { 0,0,0,1,0,0, 0,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static long test_di[18] = { 1,1,1,1,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; static void do_di (void) @@ -94,7 +97,7 @@ do_di (void) abort (); if (__sync_fetch_and_xor(AL+10, 9) != 0) abort (); - if (__sync_fetch_and_nand(AL+11, 7) != 0) + if (__sync_fetch_and_nand(AL+11, 7) != -1) abort (); if (__sync_add_and_fetch(AL+12, 1) != 1) @@ -107,7 +110,7 @@ do_di (void) abort (); if (__sync_xor_and_fetch(AL+16, 9) != 9) abort (); - if (__sync_nand_and_fetch(AL+17, 7) != 7) + if (__sync_nand_and_fetch(AL+17, 7) != ~7) abort (); } diff --git a/gcc/testsuite/gcc.dg/pr37908.c b/gcc/testsuite/gcc.dg/pr37908.c new file mode 100644 index 00000000000..d9278075ef2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr37908.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options "-Wsync-nand" } */ +/* { dg-options "-Wsync-nand -march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-options "-Wsync-nand -mcpu=v9" { target sparc*-*-* } } */ + + +extern void abort (void); + +int main (void) +{ + + short xLoc; + short xIn, xOut, xExpect, i = 1; + + xLoc = xIn = ~ (1 << i); + xExpect = ~ (xIn & 0x7F); + + xOut = __sync_nand_and_fetch (&xLoc, 0x7F); /* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" } */ + + if (xOut != xExpect) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/sync-2.c b/gcc/testsuite/gcc.dg/sync-2.c index d0e3f2cbe77..7fea8f8fd03 100644 --- a/gcc/testsuite/gcc.dg/sync-2.c +++ b/gcc/testsuite/gcc.dg/sync-2.c @@ -4,18 +4,17 @@ /* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ +/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + /* Test functionality of the intrinsics for 'short' and 'char'. */ extern void abort (void); extern void *memcpy (void *, const void *, __SIZE_TYPE__); -#ifndef AI_ALIGN -#define AI_ALIGN -#endif - -static char AI[18] AI_ALIGN; -static char init_qi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 }; -static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 }; +static char AI[18]; +static char init_qi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; static void do_qi (void) @@ -34,7 +33,7 @@ do_qi (void) abort (); if (__sync_fetch_and_xor(AI+10, 9) != 0) abort (); - if (__sync_fetch_and_nand(AI+11, 7) != 0) + if (__sync_fetch_and_nand(AI+11, 7) != (char)-1) abort (); if (__sync_add_and_fetch(AI+12, 1) != 1) @@ -47,13 +46,13 @@ do_qi (void) abort (); if (__sync_xor_and_fetch(AI+16, 9) != 9) abort (); - if (__sync_nand_and_fetch(AI+17, 7) != 7) + if (__sync_nand_and_fetch(AI+17, 7) != ~7) abort (); } static short AL[18]; -static short init_hi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 }; -static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 }; +static short init_hi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; static void do_hi (void) @@ -72,7 +71,7 @@ do_hi (void) abort (); if (__sync_fetch_and_xor(AL+10, 9) != 0) abort (); - if (__sync_fetch_and_nand(AL+11, 7) != 0) + if (__sync_fetch_and_nand(AL+11, 7) != -1) abort (); if (__sync_add_and_fetch(AL+12, 1) != 1) @@ -85,7 +84,7 @@ do_hi (void) abort (); if (__sync_xor_and_fetch(AL+16, 9) != 9) abort (); - if (__sync_nand_and_fetch(AL+17, 7) != 7) + if (__sync_nand_and_fetch(AL+17, 7) != ~7) abort (); } diff --git a/gcc/testsuite/gcc.dg/sync-3.c b/gcc/testsuite/gcc.dg/sync-3.c index bf8abb785de..a359d162fee 100644 --- a/gcc/testsuite/gcc.dg/sync-3.c +++ b/gcc/testsuite/gcc.dg/sync-3.c @@ -1,10 +1,102 @@ /* { dg-do run } */ /* { dg-require-effective-target sync_char_short } */ -/* { dg-options "-O2" } */ -/* { dg-options "-march=i486 -O2" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ -/* { dg-options "-mcpu=v9 -O2" { target sparc*-*-* } } */ +/* { dg-options "-ansi" } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ /* Test functionality of the intrinsics for 'short' and 'char'. */ -#define AI_ALIGN __attribute__((__aligned__ (4))) -#include "sync-2.c" +extern void abort (void); +extern void *memcpy (void *, const void *, __SIZE_TYPE__); + +static char AI[18] __attribute__((__aligned__ (4))); +static char init_qi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_qi (void) +{ + if (__sync_fetch_and_add(AI+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AI+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AI+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AI+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AI+8, 7) != (char)-1) + abort (); + if (__sync_fetch_and_or(AI+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AI+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AI+11, 7) != (char)-1) /* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" } */ + abort (); + + if (__sync_add_and_fetch(AI+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AI+13, 12) != (char)-12) + abort (); + if (__sync_and_and_fetch(AI+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AI+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AI+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AI+17, 7) != ~7) /* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" } */ + abort (); +} + +static short AL[18]; +static short init_hi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_hi (void) +{ + if (__sync_fetch_and_add(AL+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AL+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AL+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AL+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AL+8, 7) != -1) + abort (); + if (__sync_fetch_and_or(AL+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AL+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AL+11, 7) != -1) + abort (); + + if (__sync_add_and_fetch(AL+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AL+13, 12) != -12) + abort (); + if (__sync_and_and_fetch(AL+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AL+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AL+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AL+17, 7) != ~7) + abort (); +} + +int main() +{ + memcpy(AI, init_qi, sizeof(init_qi)); + memcpy(AL, init_hi, sizeof(init_hi)); + + do_qi (); + do_hi (); + + if (memcmp (AI, test_qi, sizeof(test_qi))) + abort (); + if (memcmp (AL, test_hi, sizeof(test_hi))) + abort (); + + return 0; +} |