static bool should_replace_address (rtx old_rtx, rtx new_rtx, machine_mode mode, addr_space_t as, bool speed) { int gain; if (rtx_equal_p (old_rtx, new_rtx) || !memory_address_addr_space_p (mode, new_rtx, as)) return false; /* Copy propagation is always ok. */ if (REG_P (old_rtx) && REG_P (new_rtx)) return true; /* Prefer the new address if it is less expensive. */ gain = (address_cost (old_rtx, mode, as, speed) - address_cost (new_rtx, mode, as, speed)); /* If the addresses have equivalent cost, prefer the new address if it has the highest `set_src_cost'. That has the potential of eliminating the most insns without additional costs, and it is the same that cse.c used to do. */ if (gain == 0) gain = (set_src_cost (new_rtx, VOIDmode, speed) - set_src_cost (old_rtx, VOIDmode, speed)); return (gain > 0); }
rtx gen_lowpart_if_possible (machine_mode mode, rtx x) { rtx result = gen_lowpart_common (mode, x); if (result) return result; else if (MEM_P (x)) { /* This is the only other case we handle. */ poly_int64 offset = byte_lowpart_offset (mode, GET_MODE (x)); rtx new_rtx = adjust_address_nv (x, mode, offset); if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0), MEM_ADDR_SPACE (x))) return 0; return new_rtx; } else if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode && validate_subreg (mode, GET_MODE (x), x, subreg_lowpart_offset (mode, GET_MODE (x)))) return gen_lowpart_SUBREG (mode, x); else return 0; }
static bool valid_mem_ref_p (enum machine_mode mode, addr_space_t as, struct mem_address *addr) { rtx address; address = addr_for_mem_ref (addr, as, false); if (!address) return false; return memory_address_addr_space_p (mode, address, as); }