https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88001
Claudiu Zissulescu <claziss at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |claziss at gmail dot com
--- Comment #1 from Claudiu Zissulescu <claziss at gmail dot com> ---
My solution, on a side branch, is this patch, but we need it to run also for
mainline gcc as we cannot build glibc or uclibc toolchains. Any help is
appreciated.
---
gcc/function.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/gcc/function.c b/gcc/function.c
index 302438323c8..36227f77074 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -6374,6 +6374,37 @@ make_pass_thread_prologue_and_epilogue (gcc::context
*ctxt)
}
+/* Helper match_asm_constraints_1. */
+static int
+constant_overlap_mentioned_p (const_rtx x, const_rtx in)
+{
+ const char *fmt;
+ int i, j;
+
+ if (CONST_INT_P (in))
+ return 0;
+
+ if (!CONSTANT_P (in))
+ return 0;
+
+ if (x == 0)
+ return 0;
+
+ if (x == in)
+ return 1;
+
+ fmt = GET_RTX_FORMAT (GET_CODE (x));
+ for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
+ {
+ if (fmt[i] == 'e')
+ return constant_overlap_mentioned_p (XEXP (x, i), in);
+ else if (fmt[i] == 'E')
+ for (j = XVECLEN (x, i) - 1; j >= 0; j--)
+ return constant_overlap_mentioned_p (XVECEXP (x, i, j), in);
+ }
+ return 0;
+}
+
/* This mini-pass fixes fall-out from SSA in asm statements that have
in-out constraints. Say you start with
@@ -6509,7 +6540,8 @@ match_asm_constraints_1 (rtx_insn *insn, rtx *p_sets, int
noutputs)
SET_DEST (p_sets[j]) = replace_rtx (SET_DEST (p_sets[j]),
input, output);
for (j = 0; j < ninputs; j++)
- if (reg_overlap_mentioned_p (input, RTVEC_ELT (inputs, j)))
+ if (reg_overlap_mentioned_p (input, RTVEC_ELT (inputs, j))
+ || constant_overlap_mentioned_p (RTVEC_ELT (inputs, j), input))
RTVEC_ELT (inputs, j) = replace_rtx (RTVEC_ELT (inputs, j),
input, output);
--
2.19.1