PR target/59229
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Nov 2013 21:28:26 +0000 (21:28 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Nov 2013 21:28:26 +0000 (21:28 +0000)
* config/i386/i386.c (device_alg): Fix up formatting.
(ix86_expand_set_or_movmem): Handle max_size < epilogue_size_needed
similarly to count && count < epilogue_size_needed.  Fix up
comment typo.
* builtins.c (determine_block_size): Fix comment typo.

* gcc.c-torture/execute/pr59229.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205416 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr59229.c [new file with mode: 0644]

index 3a18e50..7510537 100644 (file)
@@ -1,5 +1,12 @@
 2013-11-26  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/59229
+       * config/i386/i386.c (device_alg): Fix up formatting.
+       (ix86_expand_set_or_movmem): Handle max_size < epilogue_size_needed
+       similarly to count && count < epilogue_size_needed.  Fix up
+       comment typo.
+       * builtins.c (determine_block_size): Fix comment typo.
+
        PR sanitizer/59258
        * ubsan.c (ubsan_source_location): Don't add any location
        to ADDR_EXPR in the ctor.  Revert 2013-11-22 change.
index 912c14c..3f03b01 100644 (file)
@@ -3142,7 +3142,7 @@ determine_block_size (tree len, rtx len_rtx,
        }
       else if (range_type == VR_ANTI_RANGE)
        {
-         /* Anti range 0...N lets us to determine minmal size to N+1.  */
+         /* Anti range 0...N lets us to determine minimal size to N+1.  */
          if (min.is_zero ())
            {
              if ((max + double_int_one).fits_uhwi ())
@@ -3152,7 +3152,7 @@ determine_block_size (tree len, rtx len_rtx,
 
             int n;
             if (n < 100)
-              memcpy (a,b, n)
+              memcpy (a, b, n)
 
             Produce anti range allowing negative values of N.  We still
             can use the information and make a guess that N is not negative.
index 23d833e..fd4bb67 100644 (file)
@@ -23453,7 +23453,8 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size,
   /* If expected size is not known but max size is small enough
      so inline version is a win, set expected size into
      the range.  */
-  if (max > 1 && (unsigned HOST_WIDE_INT)max >= max_size && expected_size == -1)
+  if (max > 1 && (unsigned HOST_WIDE_INT) max >= max_size
+      && expected_size == -1)
     expected_size = min_size / 2 + max_size / 2;
 
   /* If user specified the algorithm, honnor it if possible.  */
@@ -23752,7 +23753,7 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx count_exp, rtx val_exp,
   bool noalign;
   enum machine_mode move_mode = VOIDmode;
   int unroll_factor = 1;
-  /* TODO: Once vlaue ranges are available, fill in proper data.  */
+  /* TODO: Once value ranges are available, fill in proper data.  */
   unsigned HOST_WIDE_INT min_size = 0;
   unsigned HOST_WIDE_INT max_size = -1;
   unsigned HOST_WIDE_INT probable_max_size = -1;
@@ -23967,21 +23968,19 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx count_exp, rtx val_exp,
         loop variant.  */
       if (issetmem && epilogue_size_needed > 2 && !promoted_val)
        force_loopy_epilogue = true;
-      if (count)
+      if ((count && count < (unsigned HOST_WIDE_INT) epilogue_size_needed)
+         || max_size < (unsigned HOST_WIDE_INT) epilogue_size_needed)
        {
-         if (count < (unsigned HOST_WIDE_INT)epilogue_size_needed)
-           {
-             /* If main algorithm works on QImode, no epilogue is needed.
-                For small sizes just don't align anything.  */
-             if (size_needed == 1)
-               desired_align = align;
-             else
-               goto epilogue;
-           }
+         /* If main algorithm works on QImode, no epilogue is needed.
+            For small sizes just don't align anything.  */
+         if (size_needed == 1)
+           desired_align = align;
+         else
+           goto epilogue;
        }
-      else if (min_size < (unsigned HOST_WIDE_INT)epilogue_size_needed)
+      else if (!count
+              && min_size < (unsigned HOST_WIDE_INT) epilogue_size_needed)
        {
-         gcc_assert (max_size >= (unsigned HOST_WIDE_INT)epilogue_size_needed);
          label = gen_label_rtx ();
          emit_cmp_and_jump_insns (count_exp,
                                   GEN_INT (epilogue_size_needed),
index fc50a05..b92f97e 100644 (file)
@@ -1,5 +1,8 @@
 2013-11-26  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/59229
+       * gcc.c-torture/execute/pr59229.c: New test.
+
        PR rtl-optimization/59166
        * gcc.dg/torture/pr59166.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59229.c b/gcc/testsuite/gcc.c-torture/execute/pr59229.c
new file mode 100644 (file)
index 0000000..d2a7767
--- /dev/null
@@ -0,0 +1,29 @@
+int i;
+
+__attribute__((noinline, noclone)) void
+bar (char *p)
+{
+  if (i < 1 || i > 6)
+    __builtin_abort ();
+  if (__builtin_memcmp (p, "abcdefg", i + 1) != 0)
+    __builtin_abort ();
+  __builtin_memset (p, ' ', 7);
+}
+
+__attribute__((noinline, noclone)) void
+foo (char *p, unsigned long l)
+{
+  if (l < 1 || l > 6)
+    return;
+  char buf[7];
+  __builtin_memcpy (buf, p, l + 1);
+  bar (buf);
+}
+
+int
+main ()
+{
+  for (i = 0; i < 16; i++)
+    foo ("abcdefghijklmnop", i);
+  return 0;
+}