re PR middle-end/10472 (ICE in instantiate_virtual_regs_lossage)

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
This commit is contained in:
Roger Sayle 2003-05-18 22:50:29 +00:00 committed by Roger Sayle
parent d1b3178b37
commit 731ae8dd8e
4 changed files with 45 additions and 6 deletions

View 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.

View 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;

View 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.

View File

@ -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));
}