i386.c (expand_movstr, [...]): Fix inline-all-stringops sequence.
authorJan Hubicka <jh@suse.cz>
Fri, 3 May 2002 20:56:42 +0000 (22:56 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 3 May 2002 20:56:42 +0000 (20:56 +0000)
* i386.c  (expand_movstr, expand_clrstr): Fix inline-all-stringops
sequence.

From-SVN: r53128

gcc/ChangeLog
gcc/config/i386/i386.c

index 6e53aa4..fc2ad3e 100644 (file)
@@ -1,3 +1,8 @@
+Fri May  3 22:53:37 CEST 2002  Jan Hubicka <jh@suse.cz>
+
+       * i386.c  (expand_movstr, expand_clrstr): Fix inline-all-stringops
+       sequence.
+
 2002-05-03  Richard Henderson  <rth@redhat.com>
 
        PR opt/6534
index 00d7d0d..b9ca483 100644 (file)
@@ -9244,6 +9244,9 @@ ix86_expand_movstr (dst, src, count_exp, align_exp)
     {
       rtx countreg2;
       rtx label = NULL;
+      int desired_alignment = (TARGET_PENTIUMPRO
+                              && (count == 0 || count >= (unsigned int) 260)
+                              ? 8 : UNITS_PER_WORD);
 
       /* In case we don't know anything about the alignment, default to
          library version, since it is usually equally fast and result in
@@ -9273,10 +9276,7 @@ ix86_expand_movstr (dst, src, count_exp, align_exp)
          This is quite costy.  Maybe we can revisit this decision later or
          add some customizability to this code.  */
 
-      if (count == 0
-         && align < (TARGET_PENTIUMPRO && (count == 0
-                                           || count >= (unsigned int) 260)
-                     ? 8 : UNITS_PER_WORD))
+      if (count == 0 && align < desired_alignment)
        {
          label = gen_label_rtx ();
          emit_cmp_and_jump_insns (countreg, GEN_INT (UNITS_PER_WORD - 1),
@@ -9298,10 +9298,7 @@ ix86_expand_movstr (dst, src, count_exp, align_exp)
          emit_label (label);
          LABEL_NUSES (label) = 1;
        }
-      if (align <= 4
-         && ((TARGET_PENTIUMPRO && (count == 0
-                                    || count >= (unsigned int) 260))
-             || TARGET_64BIT))
+      if (align <= 4 && desired_alignment > 4)
        {
          rtx label = ix86_expand_aligntest (destreg, 4);
          emit_insn (gen_strmovsi (destreg, srcreg));
@@ -9310,6 +9307,12 @@ ix86_expand_movstr (dst, src, count_exp, align_exp)
          LABEL_NUSES (label) = 1;
        }
 
+      if (label && desired_alignment > 4 && !TARGET_64BIT)
+       {
+         emit_label (label);
+         LABEL_NUSES (label) = 1;
+         label = NULL_RTX;
+       }
       if (!TARGET_SINGLE_STRINGOP)
        emit_insn (gen_cld ());
       if (TARGET_64BIT)
@@ -9455,6 +9458,10 @@ ix86_expand_clrstr (src, count_exp, align_exp)
     {
       rtx countreg2;
       rtx label = NULL;
+      /* Compute desired alignment of the string operation.  */
+      int desired_alignment = (TARGET_PENTIUMPRO
+                              && (count == 0 || count >= (unsigned int) 260)
+                              ? 8 : UNITS_PER_WORD);
 
       /* In case we don't know anything about the alignment, default to
          library version, since it is usually equally fast and result in
@@ -9469,13 +9476,10 @@ ix86_expand_clrstr (src, count_exp, align_exp)
       countreg = copy_to_mode_reg (counter_mode, count_exp);
       zeroreg = copy_to_mode_reg (Pmode, const0_rtx);
 
-      if (count == 0
-         && align < (TARGET_PENTIUMPRO && (count == 0
-                                           || count >= (unsigned int) 260)
-                     ? 8 : UNITS_PER_WORD))
+      if (count == 0 && align < desired_alignment)
        {
          label = gen_label_rtx ();
-         emit_cmp_and_jump_insns (countreg, GEN_INT (UNITS_PER_WORD - 1),
+         emit_cmp_and_jump_insns (countreg, GEN_INT (desired_alignment - 1),
                                   LEU, 0, counter_mode, 1, label);
        }
       if (align <= 1)
@@ -9496,8 +9500,7 @@ ix86_expand_clrstr (src, count_exp, align_exp)
          emit_label (label);
          LABEL_NUSES (label) = 1;
        }
-      if (align <= 4 && TARGET_PENTIUMPRO && (count == 0
-                                             || count >= (unsigned int) 260))
+      if (align <= 4 && desired_alignment > 4)
        {
          rtx label = ix86_expand_aligntest (destreg, 4);
          emit_insn (gen_strsetsi (destreg, (TARGET_64BIT
@@ -9508,6 +9511,13 @@ ix86_expand_clrstr (src, count_exp, align_exp)
          LABEL_NUSES (label) = 1;
        }
 
+      if (label && desired_alignment > 4 && !TARGET_64BIT)
+       {
+         emit_label (label);
+         LABEL_NUSES (label) = 1;
+         label = NULL_RTX;
+       }
+
       if (!TARGET_SINGLE_STRINGOP)
        emit_insn (gen_cld ());
       if (TARGET_64BIT)
@@ -9523,12 +9533,12 @@ ix86_expand_clrstr (src, count_exp, align_exp)
          emit_insn (gen_rep_stossi (destreg, countreg2, zeroreg,
                                     destreg, countreg2));
        }
-
       if (label)
        {
          emit_label (label);
          LABEL_NUSES (label) = 1;
        }
+
       if (TARGET_64BIT && align > 4 && count != 0 && (count & 4))
        emit_insn (gen_strsetsi (destreg,
                                 gen_rtx_SUBREG (SImode, zeroreg, 0)));