aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2005-05-26 08:15:31 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2005-05-26 08:15:31 +0000
commitbdb8217782c443af90a47a1b47bde9a9d305fe47 (patch)
tree7315b2174bd1d4722dd1d562258301db648721d9
parent57a95bc48d07fcd237553acf979f2e340590ed48 (diff)
downloadgcc-bdb8217782c443af90a47a1b47bde9a9d305fe47.zip
gcc-bdb8217782c443af90a47a1b47bde9a9d305fe47.tar.gz
gcc-bdb8217782c443af90a47a1b47bde9a9d305fe47.tar.bz2
simplify-rtx.c (avoid_constant_pool_reference): Support offsetted addresses in the constant pool.
2005-05-26 Paolo Bonzini <bonzini@gnu.org> * simplify-rtx.c (avoid_constant_pool_reference): Support offsetted addresses in the constant pool. From-SVN: r100198
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/simplify-rtx.c43
2 files changed, 34 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3c79b2a..ffd7b7f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2005-05-26 Paolo Bonzini <bonzini@gnu.org>
+ * simplify-rtx.c (avoid_constant_pool_reference): Support
+ offsetted addresses in the constant pool.
+
+2005-05-26 Paolo Bonzini <bonzini@gnu.org>
+
* df.h (DF_SUBREGS, df_local_def_available_p, df_insn_modified_p): New.
* df.c (DF_SUBREGS, df_local_def_available_p, df_insn_modified_p): New.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index d7e9da6..3389789 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -145,6 +145,7 @@ avoid_constant_pool_reference (rtx x)
{
rtx c, tmp, addr;
enum machine_mode cmode;
+ HOST_WIDE_INT offset = 0;
switch (GET_CODE (x))
{
@@ -173,26 +174,40 @@ avoid_constant_pool_reference (rtx x)
/* Call target hook to avoid the effects of -fpic etc.... */
addr = targetm.delegitimize_address (addr);
+ /* Split the address into a base and integer offset. */
+ if (GET_CODE (addr) == CONST
+ && GET_CODE (XEXP (addr, 0)) == PLUS
+ && GET_CODE (XEXP (XEXP (addr, 0), 1)) == CONST_INT)
+ {
+ offset = INTVAL (XEXP (XEXP (addr, 0), 1));
+ addr = XEXP (XEXP (addr, 0), 0);
+ }
+
if (GET_CODE (addr) == LO_SUM)
addr = XEXP (addr, 1);
- if (GET_CODE (addr) != SYMBOL_REF
- || ! CONSTANT_POOL_ADDRESS_P (addr))
- return x;
-
- c = get_pool_constant (addr);
- cmode = get_pool_mode (addr);
-
- /* If we're accessing the constant in a different mode than it was
- originally stored, attempt to fix that up via subreg simplifications.
- If that fails we have no choice but to return the original memory. */
- if (cmode != GET_MODE (x))
+ /* If this is a constant pool reference, we can turn it into its
+ constant and hope that simplifications happen. */
+ if (GET_CODE (addr) == SYMBOL_REF
+ && CONSTANT_POOL_ADDRESS_P (addr))
{
- c = simplify_subreg (GET_MODE (x), c, cmode, 0);
- return c ? c : x;
+ c = get_pool_constant (addr);
+ cmode = get_pool_mode (addr);
+
+ /* If we're accessing the constant in a different mode than it was
+ originally stored, attempt to fix that up via subreg simplifications.
+ If that fails we have no choice but to return the original memory. */
+ if (offset != 0 || cmode != GET_MODE (x))
+ {
+ rtx tem = simplify_subreg (GET_MODE (x), c, cmode, offset);
+ if (tem && CONSTANT_P (tem))
+ return tem;
+ }
+ else
+ return c;
}
- return c;
+ return x;
}
/* Make a unary operation by first seeing if it folds and otherwise making