]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ia64.c (ia64_expand_op_and_fetch): Fix comment.
authorJakub Jelinek <jakub@redhat.com>
Wed, 26 Mar 2003 16:00:52 +0000 (17:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 26 Mar 2003 16:00:52 +0000 (17:00 +0100)
* 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

gcc/ChangeLog
gcc/config/ia64/ia64.c
gcc/config/ia64/ia64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ia64-sync-3.c [new file with mode: 0644]

index b5f15e01334aaae2e31468de1fc87f95d7ed0d45..06993a1fddc2cdf3ff705f3053fcd4fdcb5e806c 100644 (file)
@@ -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
index 01ed5d95c1e2e1e3596dcf3df02fb5ec04267bfb..b74dd593cb290e018e84bf101747ff1389a84fb2 100644 (file)
@@ -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);
index 51e3e287765173689b75464fe58275812f087c83..f1e4f87e2372cd67a24fedaea3bd24a4d71ff5b4 100644 (file)
    (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"
index 5008e7e765114cb6e5253145ec0d9995e0a424c6..3dd2328c55332629246d56db5f59c1d81079e3d7 100644 (file)
@@ -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 (file)
index 0000000..e718c11
--- /dev/null
@@ -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;
+}