microblaze testing in my tester has occasionally been failing
Warray-bounds-40 and Wstringop-overflow-9.  I finally took a little peek
because these occasional failures show up as a regression against the
prior run.

It looks like the microblaze backend is trying to inline a move of
SIZE_MAX bytes.  Ugh.  Not surprisingly the problem is the target bits
treating the size as a signed integer in a comparison.

Fixing this is pretty simple thankfully.  I didn't audit the entire
port, just microblaze_expand_block_move.

Here's what I'm installing on the trunk -- it basically ensures we treat
the size and alignment as unsigned values.  It also fixes errors with
string-large-1.c.       

Jeff



        * config/microblaze/microblaze.c (microblaze_expand_block_move): Treat
        size and alignment as unsigned.

diff --git a/gcc/config/microblaze/microblaze.c 
b/gcc/config/microblaze/microblaze.c
index 70910fd1dde..55c1becf975 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -1258,8 +1258,8 @@ microblaze_expand_block_move (rtx dest, rtx src, rtx 
length, rtx align_rtx)
 
   if (GET_CODE (length) == CONST_INT)
     {
-      HOST_WIDE_INT bytes = INTVAL (length);
-      int align = INTVAL (align_rtx);
+      unsigned HOST_WIDE_INT bytes = UINTVAL (length);
+      unsigned int align = UINTVAL (align_rtx);
 
       if (align > UNITS_PER_WORD)
        {
@@ -1267,7 +1267,7 @@ microblaze_expand_block_move (rtx dest, rtx src, rtx 
length, rtx align_rtx)
        }
       else if (align < UNITS_PER_WORD)
        {
-         if (INTVAL (length) <= MAX_MOVE_BYTES)
+         if (UINTVAL (length) <= MAX_MOVE_BYTES)
            {
              move_by_pieces (dest, src, bytes, align, RETURN_BEGIN);
              return true;
@@ -1276,14 +1276,14 @@ microblaze_expand_block_move (rtx dest, rtx src, rtx 
length, rtx align_rtx)
            return false;
        }
 
-      if (INTVAL (length) <= 2 * MAX_MOVE_BYTES)
+      if (UINTVAL (length) <= 2 * MAX_MOVE_BYTES)
        {
-         microblaze_block_move_straight (dest, src, INTVAL (length));
+         microblaze_block_move_straight (dest, src, UINTVAL (length));
          return true;
        }
       else if (optimize)
        {
-         microblaze_block_move_loop (dest, src, INTVAL (length));
+         microblaze_block_move_loop (dest, src, UINTVAL (length));
          return true;
        }
     }

Reply via email to