]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/69644 (ICE with -O on __sync_bool_compare_and_swap with short...
authorJakub Jelinek <jakub@redhat.com>
Thu, 4 Feb 2016 13:59:27 +0000 (14:59 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 4 Feb 2016 13:59:27 +0000 (14:59 +0100)
Backported from mainline
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.

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

From-SVN: r233139

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

index 3ed089bc2ed81b851c116e14b55cc34ccb0ee24b..f5e18855d4733b25d76dbb1747aa7b8b20705bdc 100644 (file)
@@ -1,3 +1,13 @@
+2016-02-04  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-02  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/67032
index 7218e279d83adeb1282186e3cf06e6557fed8704..4c6fe870e24eb169590e82fd8a3029dd23653e6e 100644 (file)
@@ -20263,6 +20263,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;
@@ -20277,10 +20280,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 5cb88b0a714f23fc3e5f48de3f9609790929aee0..0e077ca069d58dac69898d3aaaad22089361693d 100644 (file)
@@ -1,3 +1,11 @@
+2016-02-04  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2016-02-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/69644
+       * gcc.dg/pr69644.c: New test.
+
 2016-02-02  Alan Modra  <amodra@gmail.com>
 
        PR target/69548
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;
+}