This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR optimization/6086
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 30 Mar 2002 00:05:54 +0100
- Subject: [PATCH] Fix PR optimization/6086
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
It looks like Jan deleted too much code from combine_simplify_rtx in
2001-05-17 patch. Specifically, old code used to
return CLOBBER and not the original SUBREG in some cases (like
mode dependent or volatile MEM).
Ok to commit if testing succeeds?
I've simplified the original testcase to:
struct A
{
A (int x, int y);
int a, b;
int foo () { return a; }
int bar () { return b; }
};
struct B
{
virtual ~B ();
virtual A baz () const;
};
struct C
{
A foo () const;
B *c;
};
A C::foo () const
{
int x, y;
x = c->baz ().foo ();
y = c->baz ().bar ();
return A (x, y);
}
at -O+, where proper code generation can be checked e.g. in -da dumps,
but without a real ppc I'm afraid I cannot easily cook up an
executable testcase which will fail if compiled by gcc 3.1 without
this patch and succeed with gcc 3.0 or gcc 3.1 with this patch.
Franz, could you try to write something (IMHO this
is a problem which deserves a testcase)?
2002-03-29 Jakub Jelinek <jakub@redhat.com>
PR optimization/6086
* combine.c (combine_simplify_rtx): If simplify_rtx failed because
of SUBREG of volatile MEM or because the MEM was mode dependent,
return CLOBBER instead of unmodified SUBREG.
--- gcc/combine.c.jj Fri Mar 29 08:53:59 2002
+++ gcc/combine.c Fri Mar 29 23:26:24 2002
@@ -3873,6 +3873,13 @@ combine_simplify_rtx (x, op0_mode, last,
return temp;
}
+ /* Don't change the mode of the MEM if that would change the meaning
+ of the address. */
+ if (GET_CODE (SUBREG_REG (x)) == MEM
+ && (MEM_VOLATILE_P (SUBREG_REG (x))
+ || mode_dependent_address_p (XEXP (SUBREG_REG (x), 0))))
+ return gen_rtx_CLOBBER (mode, const0_rtx);
+
/* Note that we cannot do any narrowing for non-constants since
we might have been counting on using the fact that some bits were
zero. We now do this in the SET. */
Jakub