PR middle-end/54261
	* optabs.c (expand_atomic_fetch_op): Save and restore code when
	retrying after failed attempt.
From-SVN: r190463
     {
       rtx libfunc;
       bool fixup = false;
+      enum rtx_code orig_code = code;
 
       libfunc = optab_libfunc (after ? optab.fetch_after
                               : optab.fetch_before, mode);
                                          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.  */