summaryrefslogtreecommitdiff
path: root/gcc/optabs.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-12 15:18:24 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-12 15:18:24 +0000
commitac2e452f7df5e5afcf6f9e89a4ea945f0e5a2ff8 (patch)
treef8c089b7b2a05d80f4b553ce58b696eb40d98e5c /gcc/optabs.c
parent6fc3e7ad4dbcf6b4f53c35275ece783c50d1011b (diff)
downloadgcc-ac2e452f7df5e5afcf6f9e89a4ea945f0e5a2ff8.tar.gz
gcc/
PR middle-end/50873 * optabs.c (maybe_legitimize_operand_same_code): Use copy_to_mode_reg instead of force_reg. Do nothing if the address is already a non-virtual pseudo register. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182244 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/optabs.c')
-rw-r--r--gcc/optabs.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 2c3a6405ab9..0d5cd73c3a2 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -8242,24 +8242,31 @@ maybe_legitimize_operand_same_code (enum insn_code icode, unsigned int opno,
return true;
/* If the operand is a memory whose address has no side effects,
- try forcing the address into a register. The check for side
- effects is important because force_reg cannot handle things
- like auto-modified addresses. */
- if (insn_data[(int) icode].operand[opno].allows_mem
- && MEM_P (op->value)
- && !side_effects_p (XEXP (op->value, 0)))
- {
- rtx addr, mem, last;
-
- last = get_last_insn ();
- addr = force_reg (Pmode, XEXP (op->value, 0));
- mem = replace_equiv_address (op->value, addr);
- if (insn_operand_matches (icode, opno, mem))
+ try forcing the address into a non-virtual pseudo register.
+ The check for side effects is important because copy_to_mode_reg
+ cannot handle things like auto-modified addresses. */
+ if (insn_data[(int) icode].operand[opno].allows_mem && MEM_P (op->value))
+ {
+ rtx addr, mem;
+
+ mem = op->value;
+ addr = XEXP (mem, 0);
+ if (!(REG_P (addr) && REGNO (addr) > LAST_VIRTUAL_REGISTER)
+ && !side_effects_p (addr))
{
- op->value = mem;
- return true;
+ rtx last;
+ enum machine_mode mode;
+
+ last = get_last_insn ();
+ mode = targetm.addr_space.address_mode (MEM_ADDR_SPACE (mem));
+ mem = replace_equiv_address (mem, copy_to_mode_reg (mode, addr));
+ if (insn_operand_matches (icode, opno, mem))
+ {
+ op->value = mem;
+ return true;
+ }
+ delete_insns_since (last);
}
- delete_insns_since (last);
}
return false;