[PATCH, rtl-optimization]: Fix PR88948, store-motion pass creates unrecognisable insn
Uros Bizjak
ubizjak@gmail.com
Thu Jan 24 14:06:00 GMT 2019
On Thu, Jan 24, 2019 at 12:52 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
> Another potential problem is that gen_move_insn should only really
> be used for general_operands.
>
> process_insert_insn seems to get this right, so it'd probably be
> cleanest to split the innards out into something that takes the dest
> and source rtxes of the move, then reuse that here.
Something like the attached patch?
2019-01-24 Uroš Bizjak <ubizjak@gmail.com>
PR target/88948
* rtl.h (prepare_copy_insn): New prototype.
* gcse.c (prepare_copy_insn): New function, split out from
process_insert_insn.
(process_insert_insn): Use prepare_copy_insn.
* store-motion.c (replace_store_insn): Use prepare_copy_insn
instead of gen_move_insn.
testsuite/ChangeLog:
2019-01-24 Uroš Bizjak <ubizjak@gmail.com>
PR target/88948
* gcc.target/i386/pr88948.c: New test.
Bootstrap and regression test on x86_64-linux-gnu {,-m32} in progress.
Uros.
-------------- next part --------------
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 35716cd38838..6c77671fe311 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -1963,14 +1963,11 @@ pre_expr_reaches_here_p (basic_block occr_bb, struct gcse_expr *expr, basic_bloc
return rval;
}
-/* Generate RTL to copy an EXPR to its `reaching_reg' and return it. */
+/* Generate RTL to copy an EXP to REG and return it. */
-static rtx_insn *
-process_insert_insn (struct gcse_expr *expr)
+rtx_insn *
+prepare_copy_insn (rtx reg, rtx exp)
{
- rtx reg = expr->reaching_reg;
- /* Copy the expression to make sure we don't have any sharing issues. */
- rtx exp = copy_rtx (expr->expr);
rtx_insn *pat;
start_sequence ();
@@ -1996,6 +1993,18 @@ process_insert_insn (struct gcse_expr *expr)
return pat;
}
+/* Generate RTL to copy an EXPR to its `reaching_reg' and return it. */
+
+static rtx_insn *
+process_insert_insn (struct gcse_expr *expr)
+{
+ rtx reg = expr->reaching_reg;
+ /* Copy the expression to make sure we don't have any sharing issues. */
+ rtx exp = copy_rtx (expr->expr);
+
+ return prepare_copy_insn (reg, exp);
+}
+
/* Add EXPR to the end of basic block BB.
This is used by both the PRE and code hoisting. */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 70891e6e3646..f99191983d39 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -4078,6 +4078,9 @@ extern void init_lower_subreg (void);
/* In gcse.c */
extern bool can_copy_p (machine_mode);
extern bool can_assign_to_reg_without_clobbers_p (rtx, machine_mode);
+extern rtx_insn *prepare_copy_insn (rtx, rtx);
+
+/* In cprop.c */
extern rtx fis_get_condition (rtx_insn *);
/* In ira.c */
diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index 28c4825b343d..a0838f68ba0f 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -912,8 +912,7 @@ replace_store_insn (rtx reg, rtx_insn *del, basic_block bb,
rtx_insn *insn;
rtx mem, note, set;
- mem = smexpr->pattern;
- insn = gen_move_insn (reg, SET_SRC (single_set (del)));
+ insn = prepare_copy_insn (reg, SET_SRC (single_set (del)));
unsigned int i;
rtx_insn *temp;
@@ -946,6 +945,7 @@ replace_store_insn (rtx reg, rtx_insn *del, basic_block bb,
/* Now we must handle REG_EQUAL notes whose contents is equal to the mem;
they are no longer accurate provided that they are reached by this
definition, so drop them. */
+ mem = smexpr->pattern;
for (; insn != NEXT_INSN (BB_END (bb)); insn = NEXT_INSN (insn))
if (NONDEBUG_INSN_P (insn))
{
More information about the Gcc-patches
mailing list