re PR middle-end/54261 (reverse sync/atomic operators when only sync_compare_and_swap...
authorHans-Peter Nilsson <hp@gcc.gnu.org>
Fri, 17 Aug 2012 00:18:35 +0000 (00:18 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Fri, 17 Aug 2012 00:18:35 +0000 (00:18 +0000)
PR middle-end/54261
* optabs.c (expand_atomic_fetch_op): Save and restore code when
retrying after failed attempt.

From-SVN: r190463

gcc/optabs.c

index b2f873f..ebb2af5 100644 (file)
@@ -7826,6 +7826,7 @@ expand_atomic_fetch_op (rtx target, rtx mem, rtx val, enum rtx_code code,
     {
       rtx libfunc;
       bool fixup = false;
+      enum rtx_code orig_code = code;
 
       libfunc = optab_libfunc (after ? optab.fetch_after
                               : optab.fetch_before, mode);
@@ -7849,6 +7850,9 @@ expand_atomic_fetch_op (rtx target, rtx mem, rtx val, enum rtx_code code,
                                          true, OPTAB_LIB_WIDEN);
          return result;
        }
+
+      /* We need the original code for any further attempts.  */
+      code = orig_code;
     }
 
   /* If nothing else has succeeded, default to a compare and swap loop.  */