This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFT/RFA] Fix AIX fallout from PR/19653 patch
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: David Edelsohn <dje at watson dot ibm dot com>
- Date: Tue, 04 Apr 2006 18:21:06 +0200
- Subject: [RFT/RFA] Fix AIX fallout from PR/19653 patch
This patch fixes numerous failures that the PR/19653 patch introduced on
AIX. The failures could in principle be visible on other rs6000
subtargets that have TOC, but looking at posted testresults these seem
unaffected.
The problem is that constant_pool_expr_p returns true if a SYMBOL_REF is
present in its argument; on the other hand, its users all call
get_pool_constant on the same argument as if it was a SYMBOL_REF:
...
else if (TARGET_TOC
&& constant_pool_expr_p (x)
&& ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x),
Pmode))
...
This looks like a latent bug to me, but I have not yet investigate why,
after the PR/19653 patch, we are requesting legitimization of a (const
(plus (symbol_ref LC..0) (const_int 4))). I think it is Dale's regclass
changes, but I'm not sure.
Since constant_pool_expr_p calls ASM_OUTPUT_SPECIAL_POOL_ENTRY_P, but
always with Pmode mode, my solution is to add an argument to
constant_pool_expr_p so that it calls ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
with the correct mode. This fixes the failing testcases I tried it on,
but I am not familiar with these parts of the back-ends and I am not
sure it is correct. `svn annotate' has not been helpful in decyphering
the history of these bits.
David, can you bootstrap this? Ok for mainline if it works?
Paolo
This patch fixes numerous failures that the PR/19653 patch introduced on
AIX. The failures could in principle be visible on other rs6000 subtargets
that have TOC, but looking at posted testresults these seem unaffected.
The problem is that constant_pool_expr_p returns true if a SYMBOL_REF
is present in its argument; on the other hand, its users all call
get_pool_constant on the same argument as if it was a SYMBOL_REF:
...
else if (TARGET_TOC
&& constant_pool_expr_p (x)
&& ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
...
This looks like a latent bug to me, but it may as well be a problem with
my reload changes (or Dale's regclass change -- could be as likely).
Since constant_pool_expr_p calls ASM_OUTPUT_SPECIAL_POOL_ENTRY_P, but always
with Pmode mode, my solution is to add an argument to constant_pool_expr_p
so that it calls ASM_OUTPUT_SPECIAL_POOL_ENTRY_P with the correct mode.
This fixes the failing testcases I tried it on, but I am not familiar with
these parts of the back-ends and I am not sure it is correct. `svn
annotate' has not been helpful in decyphering the history of these bits.
David, can you bootstrap this? Ok for mainline if it works?
Paolo
2006-04-04 Paolo Bonzini <bonzini@gnu.org>
* rs6000.c (constant_pool_expr_1): Add MODE parameter defaulting
to the pool constant's mode.
(constant_pool_expr_p): Add a MODE parameter, pass it.
(toc_relative_expr_p): Adjust call.
(legitimate_constant_pool_address_p, rs6000_legitimize_reload_address,
rs6000_emit_move): Merge invocations of ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
with preceding calls to constant_pool_expr_p.
Index: rs6000.c
===================================================================
--- rs6000.c (revision 112658)
+++ rs6000.c (working copy)
@@ -588,8 +588,8 @@ static void rs6000_emit_allocate_stack (
static unsigned rs6000_hash_constant (rtx);
static unsigned toc_hash_function (const void *);
static int toc_hash_eq (const void *, const void *);
-static int constant_pool_expr_1 (rtx, int *, int *);
-static bool constant_pool_expr_p (rtx);
+static int constant_pool_expr_1 (rtx, enum machine_mode, int *, int *);
+static bool constant_pool_expr_p (rtx, enum machine_mode);
static bool legitimate_small_data_p (enum machine_mode, rtx);
static bool legitimate_indexed_address_p (rtx, int);
static bool legitimate_lo_sum_address_p (enum machine_mode, rtx, int);
@@ -2642,7 +2642,8 @@ gpr_or_gpr_p (rtx op0, rtx op1)
/* Subroutines of rs6000_legitimize_address and rs6000_legitimate_address. */
static int
-constant_pool_expr_1 (rtx op, int *have_sym, int *have_toc)
+constant_pool_expr_1 (rtx op, enum machine_mode mode,
+ int *have_sym, int *have_toc)
{
switch (GET_CODE (op))
{
@@ -2651,7 +2652,9 @@ constant_pool_expr_1 (rtx op, int *have_
return 0;
else if (CONSTANT_POOL_ADDRESS_P (op))
{
- if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), Pmode))
+ if (mode == VOIDmode)
+ mode = get_pool_mode (op);
+ if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (op), mode))
{
*have_sym = 1;
return 1;
@@ -2668,10 +2671,10 @@ constant_pool_expr_1 (rtx op, int *have_
return 0;
case PLUS:
case MINUS:
- return (constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc)
- && constant_pool_expr_1 (XEXP (op, 1), have_sym, have_toc));
+ return (constant_pool_expr_1 (XEXP (op, 0), mode, have_sym, have_toc)
+ && constant_pool_expr_1 (XEXP (op, 1), mode, have_sym, have_toc));
case CONST:
- return constant_pool_expr_1 (XEXP (op, 0), have_sym, have_toc);
+ return constant_pool_expr_1 (XEXP (op, 0), mode, have_sym, have_toc);
case CONST_INT:
return 1;
default:
@@ -2680,11 +2683,11 @@ constant_pool_expr_1 (rtx op, int *have_
}
static bool
-constant_pool_expr_p (rtx op)
+constant_pool_expr_p (rtx op, enum machine_mode mode)
{
int have_sym = 0;
int have_toc = 0;
- return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_sym;
+ return constant_pool_expr_1 (op, mode, &have_sym, &have_toc) && have_sym;
}
bool
@@ -2692,7 +2695,7 @@ toc_relative_expr_p (rtx op)
{
int have_sym = 0;
int have_toc = 0;
- return constant_pool_expr_1 (op, &have_sym, &have_toc) && have_toc;
+ return constant_pool_expr_1 (op, Pmode, &have_sym, &have_toc) && have_toc;
}
bool
@@ -2702,7 +2705,7 @@ legitimate_constant_pool_address_p (rtx
&& GET_CODE (x) == PLUS
&& GET_CODE (XEXP (x, 0)) == REG
&& (TARGET_MINIMAL_TOC || REGNO (XEXP (x, 0)) == TOC_REGISTER)
- && constant_pool_expr_p (XEXP (x, 1)));
+ && constant_pool_expr_p (XEXP (x, 1), Pmode));
}
static bool
@@ -3005,8 +3008,7 @@ rs6000_legitimize_address (rtx x, rtx ol
return gen_rtx_LO_SUM (Pmode, reg, x);
}
else if (TARGET_TOC
- && constant_pool_expr_p (x)
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
+ && constant_pool_expr_p (x, Pmode))
{
return create_TOC_reference (x);
}
@@ -3440,8 +3442,7 @@ rs6000_legitimize_reload_address (rtx x,
}
if (TARGET_TOC
- && constant_pool_expr_p (x)
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
+ && constant_pool_expr_p (x, mode))
{
(x) = create_TOC_reference (x);
*win = 1;
@@ -4112,9 +4113,7 @@ rs6000_emit_move (rtx dest, rtx source,
reference to it. */
if (TARGET_TOC
&& GET_CODE (operands[1]) == SYMBOL_REF
- && constant_pool_expr_p (operands[1])
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (operands[1]),
- get_pool_mode (operands[1])))
+ && constant_pool_expr_p (operands[1], VOIDmode))
{
operands[1] = create_TOC_reference (operands[1]);
}
@@ -4179,10 +4178,7 @@ rs6000_emit_move (rtx dest, rtx source,
operands[1] = force_const_mem (mode, operands[1]);
if (TARGET_TOC
- && constant_pool_expr_p (XEXP (operands[1], 0))
- && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (
- get_pool_constant (XEXP (operands[1], 0)),
- get_pool_mode (XEXP (operands[1], 0))))
+ && constant_pool_expr_p (XEXP (operands[1], 0), VOIDmode))
{
operands[1]
= gen_const_mem (mode,