From: Jakub Jelinek Date: Wed, 26 Mar 2003 16:00:52 +0000 (+0100) Subject: ia64.c (ia64_expand_op_and_fetch): Fix comment. X-Git-Tag: releases/gcc-3.4.0~7654 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=be565ad7dfb253836b579f666b230fd261a19913;p=thirdparty%2Fgcc.git ia64.c (ia64_expand_op_and_fetch): Fix comment. * config/ia64/ia64.c (ia64_expand_op_and_fetch): Fix comment. (ia64_expand_compare_and_swap): Use always DImode ar.ccv, zero extend old to it. * config/ia64/ia64.md (cmpxchg_acq_si): Remove mode from ccv operand. * gcc.dg/ia64-sync-3.c: New test. From-SVN: r64895 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b5f15e01334a..06993a1fddc2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2003-03-26 Jakub Jelinek + + * config/ia64/ia64.c (ia64_expand_op_and_fetch): Fix comment. + (ia64_expand_compare_and_swap): Use always DImode ar.ccv, + zero extend old to it. + * config/ia64/ia64.md (cmpxchg_acq_si): Remove mode from ccv + operand. + 2003-03-26 Eric Botcazou PR target/7784 diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 01ed5d95c1e2..b74dd593cb29 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -8047,7 +8047,7 @@ ia64_expand_fetch_and_op (binoptab, mode, arglist, target) do { old = tmp; ar.ccv = tmp; - ret = tmp + value; + ret = tmp value; cmpxchgsz.acq tmp = [ptr], ret } while (tmp != old) */ @@ -8150,8 +8150,15 @@ ia64_expand_compare_and_swap (mode, boolp, arglist, target) else tmp = gen_reg_rtx (mode); - ccv = gen_rtx_REG (mode, AR_CCV_REGNUM); - emit_move_insn (ccv, old); + ccv = gen_rtx_REG (DImode, AR_CCV_REGNUM); + if (mode == DImode) + emit_move_insn (ccv, old); + else + { + rtx ccvtmp = gen_reg_rtx (DImode); + emit_insn (gen_zero_extendsidi2 (ccvtmp, old)); + emit_move_insn (ccv, ccvtmp); + } emit_insn (gen_mf ()); if (mode == SImode) insn = gen_cmpxchg_acq_si (tmp, mem, new, ccv); diff --git a/gcc/config/ia64/ia64.md b/gcc/config/ia64/ia64.md index 51e3e2877651..f1e4f87e2372 100644 --- a/gcc/config/ia64/ia64.md +++ b/gcc/config/ia64/ia64.md @@ -5428,7 +5428,7 @@ (set (match_operand:SI 1 "not_postinc_memory_operand" "+S") (unspec:SI [(match_dup 1) (match_operand:SI 2 "gr_register_operand" "r") - (match_operand:SI 3 "ar_ccv_reg_operand" "")] + (match_operand 3 "ar_ccv_reg_operand" "")] UNSPEC_CMPXCHG_ACQ))] "" "cmpxchg4.acq %0 = %1, %2, %3" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5008e7e76511..3dd2328c5533 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-03-26 Jakub Jelinek + + * gcc.dg/ia64-sync-3.c: New test. + 2003-03-26 Alan Modra * gcc.dg/loop-2.c: Replace "inline" with "__inline__". diff --git a/gcc/testsuite/gcc.dg/ia64-sync-3.c b/gcc/testsuite/gcc.dg/ia64-sync-3.c new file mode 100644 index 000000000000..e718c1115e29 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ia64-sync-3.c @@ -0,0 +1,74 @@ +/* { dg-do run { target ia64-*-* } } */ +/* { dg-options } */ + +/* Test basic functionality of the intrinsics. */ + +#include + +static int AI[4]; +static int init_si[4] = { -30,-30,-50,-50 }; +static int test_si[4] = { -115,-115,25,25 }; + +static void +do_si (void) +{ + if (__sync_val_compare_and_swap(AI+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AI+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1) + abort (); +} + +static long AL[4]; +static long init_di[4] = { -30,-30,-50,-50 }; +static long test_di[4] = { -115,-115,25,25 }; + +static void +do_di (void) +{ + if (__sync_val_compare_and_swap(AL+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AL+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1) + abort (); +} + +int main() +{ + memcpy(AI, init_si, sizeof(init_si)); + memcpy(AL, init_di, sizeof(init_di)); + + do_si (); + do_di (); + + if (memcmp (AI, test_si, sizeof(test_si))) + abort (); + if (memcmp (AL, test_di, sizeof(test_di))) + abort (); + + return 0; +}