diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-10-27 16:37:11 +0100 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-10-27 16:37:11 +0100 |
commit | 2672c60917d12260154de5d7bf668c55f2a0e62e (patch) | |
tree | c664f268a1987c6dbf51a177bcfa5f95ac418cec /gcc | |
parent | 6ff8b93c7b0bf3913fb7754f9985e7e31c46d89c (diff) | |
download | gcc-2672c60917d12260154de5d7bf668c55f2a0e62e.zip gcc-2672c60917d12260154de5d7bf668c55f2a0e62e.tar.gz gcc-2672c60917d12260154de5d7bf668c55f2a0e62e.tar.bz2 |
recog: Fix propagation into ASM_OPERANDS
An inline asm with multiple output operands is represented as a
parallel set in which the SET_SRCs are the same (shared) ASM_OPERANDS.
insn_propagation didn't account for this, and instead propagated
into each ASM_OPERANDS individually. This meant that it could
apply a substitution X->Y to Y itself, which (a) could create
circularity and (b) would be semantically wrong in any case,
since Y might use a different value of X.
This patch checks explicitly for parallels involving ASM_OPERANDS,
just like combine does.
gcc/
* recog.cc (insn_propagation::apply_to_pattern_1): Handle shared
ASM_OPERANDS.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/recog.cc | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/gcc/recog.cc b/gcc/recog.cc index e12b4c9..3bd2d73 100644 --- a/gcc/recog.cc +++ b/gcc/recog.cc @@ -1339,13 +1339,26 @@ insn_propagation::apply_to_pattern_1 (rtx *loc) && apply_to_pattern_1 (&COND_EXEC_CODE (body))); case PARALLEL: - { - int last = XVECLEN (body, 0) - 1; - for (int i = 0; i < last; ++i) - if (!apply_to_pattern_1 (&XVECEXP (body, 0, i))) - return false; - return apply_to_pattern_1 (&XVECEXP (body, 0, last)); - } + for (int i = 0; i < XVECLEN (body, 0); ++i) + { + rtx *subloc = &XVECEXP (body, 0, i); + if (GET_CODE (*subloc) == SET) + { + if (!apply_to_lvalue_1 (SET_DEST (*subloc))) + return false; + /* ASM_OPERANDS are shared between SETs in the same PARALLEL. + Only process them on the first iteration. */ + if ((i == 0 || GET_CODE (SET_SRC (*subloc)) != ASM_OPERANDS) + && !apply_to_rvalue_1 (&SET_SRC (*subloc))) + return false; + } + else + { + if (!apply_to_pattern_1 (subloc)) + return false; + } + } + return true; case ASM_OPERANDS: for (int i = 0, len = ASM_OPERANDS_INPUT_LENGTH (body); i < len; ++i) |