re PR middle-end/10472 (ICE in instantiate_virtual_regs_lossage)
authorRoger Sayle <roger@eyesopen.com>
Sun, 18 May 2003 22:50:29 +0000 (22:50 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 18 May 2003 22:50:29 +0000 (22:50 +0000)
PR middle-end/10472
* builtins.c (expand_builtin_memcpy):  Call force_operand on
expressions and use simplify_gen_binary to create the addition.

* gcc.c-torture/compile/20030518-1.c: New test case.

Co-Authored-By: Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
Co-Authored-By: Zack Weinberg <zack@codesourcery.com>
From-SVN: r66941

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20030518-1.c [new file with mode: 0644]

index 367e99f..96f2290 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-18  Roger Sayle  <roger@eyesopen.com>
+           Zack Weinberg  <zack@codesourcery.com>
+
+       PR middle-end/10472
+       * builtins.c (expand_builtin_memcpy):  Call force_operand on
+       expressions and use simplify_gen_binary to create the addition.
+
 2003-05-18  Andreas Schwab  <schwab@suse.de>
 
        * config/m68k/m68k.md: Use define_constants for unspec numbers.
index c3965e9..c3cb06d 100644 (file)
@@ -2311,10 +2311,15 @@ expand_builtin_memcpy (arglist, target, mode, endp)
 #endif
          if (endp)
            {
-             rtx result = gen_rtx_PLUS (GET_MODE (dest_mem), dest_mem, len_rtx);
+             rtx result;
+             rtx delta = len_rtx;
+
              if (endp == 2)
-               result = simplify_gen_binary (MINUS, GET_MODE (result), result, const1_rtx);
-             return result;
+               delta = GEN_INT (INTVAL (delta) - 1);
+
+             result = simplify_gen_binary (PLUS, GET_MODE (dest_mem),
+                                           dest_mem, delta);
+             return force_operand (result, NULL_RTX);
            }
          else
            return dest_mem;
@@ -2338,10 +2343,18 @@ expand_builtin_memcpy (arglist, target, mode, endp)
 
       if (endp)
         {
-         rtx result = gen_rtx_PLUS (GET_MODE (dest_addr), dest_addr, len_rtx);
+         rtx result = force_operand (len_rtx, NULL_RTX);
+
          if (endp == 2)
-           result = simplify_gen_binary (MINUS, GET_MODE (result), result, const1_rtx);
-         return result;
+           {
+             result = simplify_gen_binary (MINUS, GET_MODE (result),
+                                           result, const1_rtx);
+             result = force_operand (result, NULL_RTX);
+           }
+
+         result = simplify_gen_binary (PLUS, GET_MODE (dest_addr),
+                                       dest_addr, result);
+         return force_operand (result, NULL_RTX);
        }
       else
        return dest_addr;
index f2aa0b2..9d036cc 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-18  Roger Sayle  <roger@eyesopen.com>
+           Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * gcc.c-torture/compile/20030518-1.c: New test case.
+
 2003-05-18  Mark Mitchell  <mark@codesourcery.com>
 
        * lib/gcc-dg.exp (gcc-dg-debug-runtest): Add opt_opts parameter.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20030518-1.c b/gcc/testsuite/gcc.c-torture/compile/20030518-1.c
new file mode 100644 (file)
index 0000000..8cf2034
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test case from PR middle-end/10472  */
+
+extern void f (char *);
+
+void foo (char *s)
+{
+  f (__builtin_stpcpy (s, "hi"));
+}
+
+void bar (char *s)
+{
+  f (__builtin_mempcpy (s, "hi", 3));
+}
+