[gcc] string operations: read sandboxing

Review URL: http://codereview.chromium.org/3037021
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 2a1d573..a29f022 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -19536,7 +19536,17 @@
 	(plus:DI (match_dup 3)
 		 (const_int 8)))]
   "TARGET_64BIT"
-  "movsq"
+{
+ if (TARGET_NACL)
+  {
+    return "movsq %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
+	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
+  }
+ else
+  {
+    return "movsq";
+ }
+}
   [(set_attr "type" "str")
    (set_attr "mode" "DI")
    (set_attr "memory" "both")])
@@ -19566,7 +19576,17 @@
 	(plus:DI (match_dup 3)
 		 (const_int 4)))]
   "TARGET_64BIT"
-  "movs{l|d}"
+{
+ if (TARGET_NACL)
+  {
+    return "movsl %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
+	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
+  }
+ else
+  {
+    return "movs{l|d}";
+ }
+}
   [(set_attr "type" "str")
    (set_attr "mode" "SI")
    (set_attr "memory" "both")])
@@ -19626,7 +19646,17 @@
 	(plus:DI (match_dup 3)
 		 (const_int 1)))]
   "TARGET_64BIT"
-  "movsb"
+{
+ if (TARGET_NACL)
+  {
+    return "movsb %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
+	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
+  }
+ else
+  {
+    return "movsb";
+ }
+}
   [(set_attr "type" "str")
    (set_attr "memory" "both")
    (set_attr "mode" "QI")])
@@ -19659,8 +19689,7 @@
 {
  if (TARGET_NACL)
   {
-    return "movl\t%%esi, %%esi\nleaq\t(%%r15,%%rsi), %%rsi\n"
-	   "rep movsq (%%rsi),%%nacl:(%%rdi),%%r15"
+    return "rep movsq %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
 	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
   }
  else
@@ -19708,8 +19737,7 @@
 {
  if (TARGET_NACL)
   {
-    return "movl\t%%esi, %%esi\nleaq\t(%%r15,%%rsi), %%rsi\n"
-	   "rep movs{l|d} (%%rsi),%%nacl:(%%rdi),%%r15"
+    return "rep movs{l|d} %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
 	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
   }
  else
@@ -19753,8 +19781,7 @@
 {
  if (TARGET_NACL)
   {
-    return "movl\t%%esi, %%esi\nleaq\t(%%r15,%%rsi), %%rsi\n"
-	   "rep movsb (%%rsi),%%nacl:(%%rdi),%%r15"
+    return "rep movsb %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
 	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
   }
  else
@@ -20207,9 +20234,7 @@
 {
  if (TARGET_NACL)
   {
-    return "movl\t%%esi, %%esi\nleaq\t(%%r15,%%rsi), %%rsi\n"
-	   "movl\t%%edi, %%edi\nleaq\t(%%r15,%%rdi), %%rdi\n"
-	   "repz cmpsb"
+    return "repz cmpsb %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
 	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
   }
  else
@@ -20272,9 +20297,7 @@
 {
  if (TARGET_NACL)
   {
-    return "movl\t%%esi, %%esi\nleaq\t(%%r15,%%rsi), %%rsi\n"
-	   "movl\t%%edi, %%edi\nleaq\t(%%r15,%%rdi), %%rdi\n"
-	   "repz cmpsb"
+    return "repz cmpsb %%nacl:(%%rsi),%%nacl:(%%rdi),%%r15"
 	   "\nmovl\t%%esi, %%esi\nmovl\t%%edi, %%edi";
   }
  else