re PR c/5681 (gcc 3.0.3 produces wrong assembler code)

PR c/5681:
	* expr.c (safe_from_p): Pass VOIDmode to true_dependence instead of
	GET_MODE (x).

	* gcc.c-torture/execute/20020213-1.c: New test.

From-SVN: r49746
This commit is contained in:
Jakub Jelinek 2002-02-13 22:49:32 +01:00 committed by Jakub Jelinek
parent ec65b2e3da
commit 21117a1708
4 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2002-02-13 Jakub Jelinek <jakub@redhat.com>
PR c/5681:
* expr.c (safe_from_p): Pass VOIDmode to true_dependence instead of
GET_MODE (x).
2002-02-13 Jakub Jelinek <jakub@redhat.com>
PR optimization/5547:

View File

@ -5728,7 +5728,7 @@ safe_from_p (x, exp, top_p)
are memory and they conflict. */
return ! (rtx_equal_p (x, exp_rtl)
|| (GET_CODE (x) == MEM && GET_CODE (exp_rtl) == MEM
&& true_dependence (exp_rtl, GET_MODE (x), x,
&& true_dependence (exp_rtl, VOIDmode, x,
rtx_addr_varies_p)));
}

View File

@ -2,6 +2,8 @@
* g++.dg/other/debug3.C: New test.
* gcc.c-torture/execute/20020213-1.c: New test.
2002-02-13 Richard Smith <richard@ex-parrot.com>
* g++.old-deja/g++.other/thunk1.C: New test.

View File

@ -0,0 +1,34 @@
/* PR c/5681
This testcase failed on IA-32 at -O0, because safe_from_p
incorrectly assumed it is safe to first write into a.a2 b-1
and then read the original value from it. */
int bar (float);
struct A {
float a1;
int a2;
} a;
int b;
void foo (void)
{
a.a2 = bar (a.a1);
a.a2 = a.a2 < b - 1 ? a.a2 : b - 1;
if (a.a2 >= b - 1)
abort ();
}
int bar (float x)
{
return 2241;
}
int main()
{
a.a1 = 1.0f;
b = 3384;
foo ();
return 0;
}