Blame SOURCES/gcc48-pr69644.patch

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