Blame SOURCES/gcc48-pr69644.patch

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