diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 231e624be899e9ef9ff93ba1d636ce56c8a803ac..392dbce60ef8f2acc42e660f168f34a5813ce727 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2012-07-03  Roland McGrath  <mcgrathr@google.com>
+
+	* configure.ac (HAVE_AS_IX86_REP_LOCK_PREFIX): Also require that the
+	assembler accept 'rep bsf ...', 'rep bsr ...', 'rep ret' and 'rep nop'.
+	* configure: Regenerated.
+	* config/i386/i386.md (simple_return_internal_long): Use %;
+	(ctz<mode>2): Likewise.
+	(*pause): Likewise.
+
 2012-07-02  Oleg Endo  <olegendo@gcc.gnu.org>
 
 	PR target/51244
@@ -30,8 +39,7 @@
 	(gen_inbound_check): Do not release post-dominator info here.
 	(process_switch): Reorder code.  Expand as bit tests if it
 	looks like a win.
-	(do_switchconv): Release post-dominator info here if something
-	changed.
+	(do_switchconv): Release post-dominator info here if something changed.
 	(struct gimple_opt_pass): Verify more.
 	* tree.h (expand_switch_using_bit_tests_p): Remove prototype.
 
@@ -42,9 +50,9 @@
 	dynamic type change check.
 
 2012-07-02  Richard Guenther  <rguenther@suse.de>
-	Michael Matz  <matz@suse.de>
-	Tobias Grosser <tobias@grosser.es>
-	Sebastian Pop <sebpop@gmail.com>
+	    Michael Matz  <matz@suse.de>
+	    Tobias Grosser <tobias@grosser.es>
+	    Sebastian Pop <sebpop@gmail.com>
 
 	* Makefile.in: Remove PPL flags in favor of ISL ones.
 	(BACKENDLIBS): Remove PPL libs.
@@ -55,8 +63,7 @@
 	(graphite-poly.o): Likewise.
 	* configure.ac: Declare ISL vars instead of PPL ones.
 	* configure: Regenerated.
-	* doc/install.texi: Replace PPL requirement documentation
-	with ISL one.
+	* doc/install.texi: Replace PPL requirement documentation with ISL one.
 	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
 	* graphite-clast-to-gimple.c: Likewise.
 	* graphite-dependences.c: Likewise.
@@ -76,7 +83,7 @@
 
 	Merge from graphite branch
 	2011-07-21  Tobias Grosser  <tobias@grosser.es>
-    
+
 	* Makefile.in (graphite-clast-to-gimple.o, graphite-cloog-util.o):
 	Remove graphite-cloog-util.h.
 	* graphite-clast-to-gimple.c (gcc_type_for_iv_of_clast_loop,
@@ -122,7 +129,7 @@
 	* graphite-clast-to-gimple.h (scop_to_clast): Remove.
 
 	2012-01-11  Tobias Grosser <tobias@grosser.es>
-    
+
 	* graphite-clast-to-gimple.c (clast_name_to_index,
 	clast_name_to_lb_ub, clast_name_to_gcc): Change types.
 	(clast_to_gcc_expression): Add clast_expr_name as a new
@@ -172,7 +179,7 @@
 	(crc32_byte): ... here.  Use it.
 	(crc32_unsigned): New.
 
-2012-06-29   Cary Coutant  <ccoutant@google.com>
+2012-06-29  Cary Coutant  <ccoutant@google.com>
 
 	* dwarf2out.c (add_pubname_string): Don't check for want_pubnames.
 	(gen_subprogram_die): Don't add pubname if want_pubnames is false.
@@ -199,8 +206,7 @@
 2012-06-29  Jakub Jelinek  <jakub@redhat.com>
 
 	* tree-vect-generic.c (expand_vector_divmod): For even/odd
-	widening multiply, put even always as first argument to
-	VEC_PERM_EXPR.
+	widening multiply, put even always as first argument to VEC_PERM_EXPR.
 
 2012-06-29  Richard Henderson  <rth@redhat.com>
 
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 60aa65a88bf005269729e375da4e300512b1d759..bdee324797c98fa251e4248897dfc01fbf484c8d 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -11904,7 +11904,7 @@
   [(simple_return)
    (unspec [(const_int 0)] UNSPEC_REP)]
   "reload_completed"
-  "rep\;ret"
+  "rep%; ret"
   [(set_attr "length" "2")
    (set_attr "atom_unit" "jeu")
    (set_attr "length_immediate" "0")
@@ -12236,8 +12236,8 @@
   else if (optimize_function_for_size_p (cfun))
     ;
   else if (TARGET_GENERIC)
-    /* tzcnt expands to rep;bsf and we can use it even if !TARGET_BMI.  */
-    return "rep; bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+    /* tzcnt expands to 'rep bsf' and we can use it even if !TARGET_BMI.  */
+    return "rep%; bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
 
   return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
 }
@@ -18131,7 +18131,7 @@
   [(set (match_operand:BLK 0)
 	(unspec:BLK [(match_dup 0)] UNSPEC_PAUSE))]
   ""
-  "rep; nop"
+  "rep%; nop"
   [(set_attr "length" "2")
    (set_attr "memory" "unknown")])
 
diff --git a/gcc/configure b/gcc/configure
index fd3be5231b80ee52aee3c83953d030b7b5bf14ca..af08a49b3495b9e5987e6375680a4e9b3ec51fb2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -24790,6 +24790,10 @@ else
   gcc_cv_as_ix86_rep_lock_prefix=no
   if test x$gcc_cv_as != x; then
     $as_echo 'rep movsl
+	 rep ret
+	 rep nop
+	 rep bsf %ecx, %eax
+	 rep bsr %ecx, %eax
 	 lock addl %edi, (%eax,%esi)
 	 lock orl $0, (%esp)' > conftest.s
     if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 89644e2dd96256f31051b0e23ed43ff71247459b..a95adecc74260adcbdbb5a2f8e980157d39c0546 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3641,6 +3641,10 @@ foo:	nop
     gcc_GAS_CHECK_FEATURE([rep and lock prefix],
         gcc_cv_as_ix86_rep_lock_prefix,,,
 	[rep movsl
+	 rep ret
+	 rep nop
+	 rep bsf %ecx, %eax
+	 rep bsr %ecx, %eax
 	 lock addl %edi, (%eax,%esi)
 	 lock orl $0, (%esp)],,
         [AC_DEFINE(HAVE_AS_IX86_REP_LOCK_PREFIX, 1,