aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2003-03-26 17:00:52 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2003-03-26 17:00:52 +0100
commitbe565ad7dfb253836b579f666b230fd261a19913 (patch)
treebcd718c3205afeb4ccd10f2f2f95cbb6a43944ff /gcc
parentf729e5592fe97fd4497578845d04a4025f180d66 (diff)
downloadgcc-be565ad7dfb253836b579f666b230fd261a19913.zip
gcc-be565ad7dfb253836b579f666b230fd261a19913.tar.gz
gcc-be565ad7dfb253836b579f666b230fd261a19913.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/ia64/ia64.c13
-rw-r--r--gcc/config/ia64/ia64.md2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/ia64-sync-3.c74
5 files changed, 97 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b5f15e0..06993a1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2003-03-26 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <ebotcazou@libertysurf.fr>
PR target/7784
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 01ed5d9..b74dd59 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 <op> 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 51e3e28..f1e4f87 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 5008e7e..3dd2328 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-03-26 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.dg/ia64-sync-3.c: New test.
+
2003-03-26 Alan Modra <amodra@bigpond.net.au>
* 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 0000000..e718c11
--- /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 <ia64intrin.h>
+
+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;
+}