summaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2008-11-17 11:19:06 +0000
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2008-11-17 11:19:06 +0000
commitcf73e559a959967a67cdd9ea5322abb7b13a3394 (patch)
treeec588937bd71d8c137cd8e58e26176a069ebf17b /gcc/builtins.c
parentd6832042f6cef05373fa6a7e77cd42989d806553 (diff)
downloadgcc-cf73e559a959967a67cdd9ea5322abb7b13a3394.tar.gz
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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141942 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index a1bba0d7160..fd6d0b859e0 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5988,6 +5988,50 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp,
rtx val, mem;
enum machine_mode old_mode;
+ if (code == NOT && warn_sync_nand)
+ {
+ tree fndecl = get_callee_fndecl (exp);
+ enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
+
+ static bool warned_f_a_n, warned_n_a_f;
+
+ switch (fcode)
+ {
+ case BUILT_IN_FETCH_AND_NAND_1:
+ case BUILT_IN_FETCH_AND_NAND_2:
+ case BUILT_IN_FETCH_AND_NAND_4:
+ case BUILT_IN_FETCH_AND_NAND_8:
+ case BUILT_IN_FETCH_AND_NAND_16:
+
+ if (warned_f_a_n)
+ break;
+
+ fndecl = implicit_built_in_decls[BUILT_IN_FETCH_AND_NAND_N];
+ inform (input_location,
+ "%qD changed semantics in GCC 4.4", fndecl);
+ warned_f_a_n = true;
+ break;
+
+ case BUILT_IN_NAND_AND_FETCH_1:
+ case BUILT_IN_NAND_AND_FETCH_2:
+ case BUILT_IN_NAND_AND_FETCH_4:
+ case BUILT_IN_NAND_AND_FETCH_8:
+ case BUILT_IN_NAND_AND_FETCH_16:
+
+ if (warned_n_a_f)
+ break;
+
+ fndecl = implicit_built_in_decls[BUILT_IN_NAND_AND_FETCH_N];
+ inform (input_location,
+ "%qD changed semantics in GCC 4.4", fndecl);
+ warned_n_a_f = true;
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+ }
+
/* Expand the operands. */
mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode);