aboutsummaryrefslogtreecommitdiff
path: root/gcc/lra-constraints.c
diff options
context:
space:
mode:
authorliuhongt <hongtao.liu@intel.com>2020-09-26 15:08:32 +0800
committerliuhongt <hongtao.liu@intel.com>2020-10-22 10:28:56 +0800
commit4de7b010038933dd6ca96bf186ca49f243d0def6 (patch)
treef6564cb47f71a34dfe28aa96dfc8f3e70b5a270d /gcc/lra-constraints.c
parent76835dca95ab9f3f106a0db1e6152ad0740b38b3 (diff)
downloadgcc-4de7b010038933dd6ca96bf186ca49f243d0def6.zip
gcc-4de7b010038933dd6ca96bf186ca49f243d0def6.tar.gz
gcc-4de7b010038933dd6ca96bf186ca49f243d0def6.tar.bz2
Extend special_memory_constraint.
For operand with special_memory_constraint, there could be a wrapper for memory_operand. Extract mem for operand for conditional judgement like MEM_P, also for record_address_regs. gcc/ChangeLog: PR target/87767 * ira-costs.c (record_operand_costs): Extract memory operand from recog_data.operand[i] for record_address_regs. (record_reg_classes): Extract memory operand from OP for conditional judgement MEM_P. * ira.c (ira_setup_alts): Ditto. * lra-constraints.c (extract_mem_from_operand): New function. (satisfies_memory_constraint_p): Extract memory operand from OP for decompose_mem_address, return false when there's no memory operand inside OP. (process_alt_operands): Remove MEM_P (op) since it would be judged in satisfies_memory_constraint_p. * recog.c (asm_operand_ok): Extract memory operand from OP for judgement of memory_operand (OP, VOIDmode). (constrain_operands): Don't unwrapper unary operator when there's memory operand inside. * rtl.h (extract_mem_from_operand): New decl.
Diffstat (limited to 'gcc/lra-constraints.c')
-rw-r--r--gcc/lra-constraints.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index f761d7d..b5c010d 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -416,14 +416,34 @@ valid_address_p (rtx op, struct address_info *ad,
return valid_address_p (ad->mode, *ad->outer, ad->as);
}
+/* For special_memory_operand, it could be false for MEM_P (op),
+ i.e. bcst_mem_operand in i386 backend.
+ Extract and return real memory operand or op. */
+rtx
+extract_mem_from_operand (rtx op)
+{
+ for (rtx x = op;; x = XEXP (x, 0))
+ {
+ if (MEM_P (x))
+ return x;
+ if (GET_RTX_LENGTH (GET_CODE (x)) != 1
+ || GET_RTX_FORMAT (GET_CODE (x))[0] != 'e')
+ break;
+ }
+ return op;
+}
+
/* Return true if the eliminated form of memory reference OP satisfies
extra (special) memory constraint CONSTRAINT. */
static bool
satisfies_memory_constraint_p (rtx op, enum constraint_num constraint)
{
struct address_info ad;
+ rtx mem = extract_mem_from_operand (op);
+ if (!MEM_P (mem))
+ return false;
- decompose_mem_address (&ad, op);
+ decompose_mem_address (&ad, mem);
address_eliminator eliminator (&ad);
return constraint_satisfied_p (op, constraint);
}
@@ -2406,8 +2426,7 @@ process_alt_operands (int only_alternative)
break;
case CT_MEMORY:
- if (MEM_P (op)
- && satisfies_memory_constraint_p (op, cn))
+ if (satisfies_memory_constraint_p (op, cn))
win = true;
else if (spilled_pseudo_p (op))
win = true;
@@ -2448,8 +2467,7 @@ process_alt_operands (int only_alternative)
break;
case CT_SPECIAL_MEMORY:
- if (MEM_P (op)
- && satisfies_memory_constraint_p (op, cn))
+ if (satisfies_memory_constraint_p (op, cn))
win = true;
else if (spilled_pseudo_p (op))
win = true;