Blame SOURCES/gcc48-pr69644.patch

56d343
2016-02-04  Jakub Jelinek  <jakub@redhat.com>
56d343
56d343
	Backported from mainline
56d343
	2016-02-03  Jakub Jelinek  <jakub@redhat.com>
56d343
56d343
	PR target/69644
56d343
	* config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap):
56d343
	Force oldval into register if it does not satisfy reg_or_short_operand
56d343
	predicate.  Fix up formatting.
56d343
56d343
	* gcc.dg/pr69644.c: New test.
56d343
56d343
--- gcc/config/rs6000/rs6000.c
56d343
+++ gcc/config/rs6000/rs6000.c
56d343
@@ -20263,6 +20263,9 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[])
56d343
   else if (reg_overlap_mentioned_p (retval, oldval))
56d343
     oldval = copy_to_reg (oldval);
56d343
 
56d343
+  if (mode != TImode && !reg_or_short_operand (oldval, mode))
56d343
+    oldval = copy_to_mode_reg (mode, oldval);
56d343
+
56d343
   mem = rs6000_pre_atomic_barrier (mem, mod_s);
56d343
 
56d343
   label1 = NULL_RTX;
56d343
@@ -20277,10 +20280,8 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[])
56d343
 
56d343
   x = retval;
56d343
   if (mask)
56d343
-    {
56d343
-      x = expand_simple_binop (SImode, AND, retval, mask,
56d343
-			       NULL_RTX, 1, OPTAB_LIB_WIDEN);
56d343
-    }
56d343
+    x = expand_simple_binop (SImode, AND, retval, mask,
56d343
+			     NULL_RTX, 1, OPTAB_LIB_WIDEN);
56d343
 
56d343
   cond = gen_reg_rtx (CCmode);
56d343
   /* If we have TImode, synthesize a comparison.  */
56d343
--- /dev/null
56d343
+++ gcc/testsuite/gcc.dg/pr69644.c
56d343
@@ -0,0 +1,11 @@
56d343
+/* PR target/69644 */
56d343
+/* { dg-do compile } */
56d343
+
56d343
+int
56d343
+main ()
56d343
+{
56d343
+  unsigned short x = 0x8000;
56d343
+  if (!__sync_bool_compare_and_swap (&x, 0x8000, 0) || x)
56d343
+    __builtin_abort ();
56d343
+  return 0;
56d343
+}