aboutsummaryrefslogtreecommitdiff
path: root/gcc/explow.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-06-18 06:33:10 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-06-18 06:33:10 -0400
commit0b04ec8c2190fe80e0799c61f42549a6194e3979 (patch)
tree9d26ee7e7eb897c8cdd301fa3f255406fc5fbaba /gcc/explow.c
parent489af5d14b2291aa2e2118819060b12be7e1a0f8 (diff)
downloadgcc-0b04ec8c2190fe80e0799c61f42549a6194e3979.zip
gcc-0b04ec8c2190fe80e0799c61f42549a6194e3979.tar.gz
gcc-0b04ec8c2190fe80e0799c61f42549a6194e3979.tar.bz2
(convert_memory_address, case PLUS, MULT): Don't commute operation
with extension if not adding small integer. From-SVN: r12292
Diffstat (limited to 'gcc/explow.c')
-rw-r--r--gcc/explow.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/gcc/explow.c b/gcc/explow.c
index 8987075..b918294 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -304,8 +304,11 @@ convert_memory_address (to_mode, x)
enum machine_mode to_mode;
rtx x;
{
+ enum machine_mode from_mode = to_mode == ptr_mode ? Pmode : ptr_mode;
rtx temp;
+ /* Here we handle some special cases. If none of them apply, fall through
+ to the default case. */
switch (GET_CODE (x))
{
case CONST_INT:
@@ -320,21 +323,25 @@ convert_memory_address (to_mode, x)
SYMBOL_REF_FLAG (temp) = SYMBOL_REF_FLAG (x);
return temp;
- case PLUS:
- case MULT:
- return gen_rtx (GET_CODE (x), to_mode,
- convert_memory_address (to_mode, XEXP (x, 0)),
- convert_memory_address (to_mode, XEXP (x, 1)));
-
case CONST:
return gen_rtx (CONST, to_mode,
convert_memory_address (to_mode, XEXP (x, 0)));
- default:
- return convert_modes (to_mode,
- to_mode == ptr_mode ? Pmode : ptr_mode,
- x, POINTERS_EXTEND_UNSIGNED);
+ case PLUS:
+ case MULT:
+ /* For addition the second operand is a small constant, we can safely
+ permute the converstion and addition operation. We can always safely
+ permute them if we are making the address narrower. */
+ if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
+ || (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == CONST_INT
+ && INTVAL (x) + 20000 < 40000))
+ return gen_rtx (GET_CODE (x), to_mode,
+ convert_memory_address (to_mode, XEXP (x, 0)),
+ convert_memory_address (to_mode, XEXP (x, 1)));
}
+
+ return convert_modes (to_mode, from_mode,
+ x, POINTERS_EXTEND_UNSIGNED);
}
#endif