re PR target/69644 (ICE with -O on __sync_bool_compare_and_swap with short in extract...
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Feb 2016 22:38:56 +0000 (23:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Feb 2016 22:38:56 +0000 (23:38 +0100)
PR target/69644
* config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap):
Force oldval into register if it does not satisfy reg_or_short_operand
predicate.  Fix up formatting.

* gcc.dg/pr69644.c: New test.

From-SVN: r233113

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr69644.c [new file with mode: 0644]

index 720dfeb1a9273a25f03ceee8defba0d6b09308b0..a3fc634f46ad65a0c6e2c0269275768f97dbc87b 100644 (file)
@@ -1,3 +1,10 @@
+2016-02-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/69644
+       * config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap):
+       Force oldval into register if it does not satisfy reg_or_short_operand
+       predicate.  Fix up formatting.
+
 2016-02-03  Vladimir Makarov  <vmakarov@redhat.com>
            Alexandre Oliva  <aoliva@redhat.com>
 
index e840a2c2d662d24a08c723630a3e533402ad275f..6f382cba9968970e84e1886a71e21adaa1e7bb0f 100644 (file)
@@ -22275,6 +22275,9 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[])
   else if (reg_overlap_mentioned_p (retval, oldval))
     oldval = copy_to_reg (oldval);
 
+  if (mode != TImode && !reg_or_short_operand (oldval, mode))
+    oldval = copy_to_mode_reg (mode, oldval);
+
   mem = rs6000_pre_atomic_barrier (mem, mod_s);
 
   label1 = NULL_RTX;
@@ -22289,10 +22292,8 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[])
 
   x = retval;
   if (mask)
-    {
-      x = expand_simple_binop (SImode, AND, retval, mask,
-                              NULL_RTX, 1, OPTAB_LIB_WIDEN);
-    }
+    x = expand_simple_binop (SImode, AND, retval, mask,
+                            NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
   cond = gen_reg_rtx (CCmode);
   /* If we have TImode, synthesize a comparison.  */
index e6b0cc6fc49573931ea32205e329b183a39f5dd0..d192485acae38941a388e31e715a00daba8d4c2c 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/69644
+       * gcc.dg/pr69644.c: New test.
+
 2016-02-03  Mike Stump  <mikestump@comcast.net>
 
        * lib/compat.exp (compat-get-options-main): Add dg-timeout-factor
diff --git a/gcc/testsuite/gcc.dg/pr69644.c b/gcc/testsuite/gcc.dg/pr69644.c
new file mode 100644 (file)
index 0000000..c60b191
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR target/69644 */
+/* { dg-do compile } */
+
+int
+main ()
+{
+  unsigned short x = 0x8000;
+  if (!__sync_bool_compare_and_swap (&x, 0x8000, 0) || x)
+    __builtin_abort ();
+  return 0;
+}