From: liuhongt Date: Mon, 26 Oct 2020 12:46:42 +0000 (+0800) Subject: Don't extract memory from operand for normal memory constraint. X-Git-Tag: upstream/12.2.0~12250 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e0aa43fc6ae689c595902310baec604e7e0d695;p=platform%2Fupstream%2Fgcc.git Don't extract memory from operand for normal memory constraint. gcc/ChangeLog PR target/97540 * ira.c: (ira_setup_alts): Extract memory from operand only for special memory constraint. * recog.c (asm_operand_ok): Ditto. * lra-constraints.c (process_alt_operands): MEM_P is required for normal memory constraint. gcc/testsuite/ChangeLog * gcc.target/i386/pr97540.c: New test. --- diff --git a/gcc/ira.c b/gcc/ira.c index bc94e15..050405f 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -1845,6 +1845,7 @@ ira_setup_alts (rtx_insn *insn) default: { enum constraint_num cn = lookup_constraint (p); + rtx mem = NULL; switch (get_constraint_type (cn)) { case CT_REGISTER: @@ -1867,8 +1868,12 @@ ira_setup_alts (rtx_insn *insn) goto op_success; case CT_MEMORY: + mem = op; + /* Fall through. */ case CT_SPECIAL_MEMORY: - if (MEM_P (extract_mem_from_operand (op))) + if (!mem) + mem = extract_mem_from_operand (op); + if (MEM_P (mem)) goto op_success; win_p = true; break; diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 22e7075..fbc47ba 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -2428,7 +2428,8 @@ process_alt_operands (int only_alternative) break; case CT_MEMORY: - if (satisfies_memory_constraint_p (op, cn)) + if (MEM_P (op) + && satisfies_memory_constraint_p (op, cn)) win = true; else if (spilled_pseudo_p (op)) win = true; diff --git a/gcc/recog.c b/gcc/recog.c index 45a52e2..6d8b7d5 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -1794,6 +1794,7 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints) /* FALLTHRU */ default: cn = lookup_constraint (constraint); + rtx mem = NULL; switch (get_constraint_type (cn)) { case CT_REGISTER: @@ -1812,10 +1813,13 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints) break; case CT_MEMORY: + mem = op; + /* Fall through. */ case CT_SPECIAL_MEMORY: /* Every memory operand can be reloaded to fit. */ - result = result || memory_operand (extract_mem_from_operand (op), - VOIDmode); + if (!mem) + mem = extract_mem_from_operand (op); + result = result || memory_operand (mem, VOIDmode); break; case CT_ADDRESS: diff --git a/gcc/testsuite/gcc.target/i386/pr97540.c b/gcc/testsuite/gcc.target/i386/pr97540.c new file mode 100644 index 0000000..20f8717 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr97540.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int mt7615_add_interface_dev_0; +int ffs(int x) { asm("" : : "rm"(x)); } +int mt7615_add_interface() { ffs(~mt7615_add_interface_dev_0); }