re PR rtl-optimization/12799 (faulty mov->add change clobbers the CC register)

PR optimization/12799
	* postreload.c (reload_cse_move2add): Generate the add2
	patterns manually.

From-SVN: r73195
This commit is contained in:
Eric Botcazou 2003-11-02 09:32:23 +01:00 committed by Eric Botcazou
parent 0a9e65f999
commit e69cdc1237
4 changed files with 58 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2003-11-02 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/12799
* postreload.c (reload_cse_move2add): Generate the add2
patterns manually.
2003-11-02 Eric Botcazou <ebotcazou@libertysurf.fr>
* config/sparc/sparc.c (function_arg_partial_nregs) [TARGET_ARCH64]:

View File

@ -1199,14 +1199,12 @@ reload_cse_move2add (rtx first)
else if (rtx_cost (new_src, PLUS) < rtx_cost (src, SET)
&& have_add2_insn (reg, new_src))
{
rtx newpat = gen_add2_insn (reg, new_src);
if (INSN_P (newpat) && NEXT_INSN (newpat) == NULL_RTX)
newpat = PATTERN (newpat);
/* If it was the first insn of a sequence or
some other emitted insn, validate_change will
reject it. */
validate_change (insn, &PATTERN (insn),
newpat, 0);
rtx newpat = gen_rtx_SET (VOIDmode,
reg,
gen_rtx_PLUS (GET_MODE (reg),
reg,
new_src));
validate_change (insn, &PATTERN (insn), newpat, 0);
}
else
{
@ -1288,10 +1286,11 @@ reload_cse_move2add (rtx first)
< COSTS_N_INSNS (1) + rtx_cost (src3, SET))
&& have_add2_insn (reg, new_src))
{
rtx newpat = gen_add2_insn (reg, new_src);
if (INSN_P (newpat)
&& NEXT_INSN (newpat) == NULL_RTX)
newpat = PATTERN (newpat);
rtx newpat = gen_rtx_SET (VOIDmode,
reg,
gen_rtx_PLUS (GET_MODE (reg),
reg,
new_src));
success
= validate_change (next, &PATTERN (next),
newpat, 0);

View File

@ -1,3 +1,7 @@
2003-11-02 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/20031102-1.c: New test.
2003-11-02 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/complex-1.c: New test.

View File

@ -0,0 +1,37 @@
/* PR optimization/12799 */
/* Origin: Pratap Subrahmanyam <pratap@vmware.com> */
/* { dg-do run } */
/* { dg-options "-O2" } */
/* { dg-options "-O2 -march=i686" { target i686-*-* } } */
/* Verify that reload_cse_move2add doesn't add unexpected CLOBBERs. */
extern void abort(void);
int loo = 1;
__inline__ char InlineFunc(void)
{
return __builtin_expect(!!(loo == 1), 1);
}
int FooBar(void)
{
int i;
int var1 = InlineFunc() ? 2046 : 1023;
int var2 = InlineFunc() ? 512 : 1024;
for (i = 0; i < var1; i++)
;
if (InlineFunc() && var2 != 512)
abort();
return 0;
}
int main(void)
{
return FooBar();
}