|
|
Peter Bergner wrote:
On Sat, 2009-06-27 at 13:07 +0200, Paolo Bonzini wrote:
I wonder how much of the performance can be kept on Power6 if you just
attack PR28690 within md_reorg. The only problem would be if the index
was allocated in r0.
What exactly did you have in mind here?
Look into each MEM looking for PLUSes with the operands in the wrong
order. Or:
static bool
is_pointer_object (rtx x)
{
if (REG_P (x))
return REG_POINTER (x);
if (MEM_P (x))
return MEM_POINTER (x);
return false;
}
/* We are inside a MEM, find PLUSes were the index comes first and
invert the base and index. DATA points to the mem within which
*PX lies, which is used to validate the address. */
static int
find_plus_and_frob_them (rtx *px, void *data)
{
if (GET_CODE (x) == PLUS
&& OBJECT_P (XEXP (x, 1))
&& OBJECT_P (XEXP (x, 0))
&& is_pointer_object (XEXP (x, 1))
&& !is_pointer_object (XEXP (x, 0))
{
rtx mem = data;
rtx t = XEXP (x, 0);
XEXP (x, 0) = XEXP (x, 1);
XEXP (x, 1) = t;
gcc_assert (!swap_commutative_operands_p (XEXP (x, 0),
XEXP (x, 1));
if (!strict_memory_address_p (GET_MODE (mem), XEXP (mem, 0)))
{
/* Too bad, probably XEXP (x, 0) is r0 and cannot be made into
an index. Undo. */
XEXP (x, 1) = XEXP (x, 0);
XEXP (x, 0) = t;
}
}
return 0;
}
/* Look for memory operands and apply find_plus_and_frob_them to their
addresses. */
static int
find_mems_and_frob_them (rtx *px, void *data)
{
if (GET_CODE (*px) == MEM)
{
for_each_rtx (&XEXP (*px, 0), find_plus_and_frob_them, *px);
return -1;
}
return 0;
}
and then in a machine-dependent reorg pass (which rs6000 currently does
not have):
FOR_EACH_BB (bb)
FOR_BB_INSNS (bb, insn)
if (INSN_P (insn))
for_each_rtx (&PATTERN (insn), find_mems_and_frob_them, NULL);
|
|