Blame SOURCES/gcc48-pr69644.patch

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