@@ -77,6 +77,7 @@ struct value_data
};
static alloc_pool debug_insn_changes_pool;
+static bool skip_debug_insn_p = false;
static void kill_value_one_regno (unsigned, struct value_data *);
static void kill_value_regno (unsigned, unsigned, struct value_data *);
@@ -485,7 +486,7 @@ replace_oldest_value_reg (rtx *loc, enum reg_class
cl, rtx insn,
struct value_data *vd)
{
rtx new_rtx = find_oldest_value_reg (cl, *loc, vd);
- if (new_rtx)
+ if (new_rtx && (!DEBUG_INSN_P (insn) || !skip_debug_insn_p))
{
if (DEBUG_INSN_P (insn))
{
@@ -1112,6 +1113,26 @@ debug_value_data (struct value_data *vd)
vd->e[i].next_regno);
}
+/* Do copyprop_hardreg_forward_1 for a single basic block BB.
+ DEBUG_INSN is skipped since we do not want to involve DF related
+ staff as how it is handled in function pass_cprop_hardreg::execute.
+
+ NOTE: Currently it is only used for shrink-wrap. Maybe extend it
+ to handle DEBUG_INSN for other uses. */
+
+void
+copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb)
+{
+ struct value_data *vd;
+ vd = XNEWVEC (struct value_data, 1);
+ init_value_data (vd);
+
+ skip_debug_insn_p = true;
+ copyprop_hardreg_forward_1 (bb, vd);
+ free (vd);
+ skip_debug_insn_p = false;
+}
+
#ifdef ENABLE_CHECKING
static void
validate_value_data (struct value_data *vd)
@@ -320,6 +320,15 @@ prepare_shrink_wrap (basic_block entry_block)
df_ref *ref;
bool split_p = false;
+ if (JUMP_P (BB_END (entry_block)))
+ {
+ /* To have more shrink-wrapping opportunities, prepare_shrink_wrap tries
+ to sink the copies from parameter to callee saved register out of
+ entry block. copyprop_hardreg_forward_bb_without_debug_insn is called
+ to release some dependences. */
+ copyprop_hardreg_forward_bb_without_debug_insn (entry_block);
+ }
+
CLEAR_HARD_REG_SET (uses);
CLEAR_HARD_REG_SET (defs);
FOR_BB_INSNS_REVERSE_SAFE (entry_block, insn, curr)
@@ -45,6 +45,8 @@ extern edge get_unconverted_simple_return (edge, bitmap_head,
extern void convert_to_simple_return (edge entry_edge, edge orig_entry_edge,
bitmap_head bb_flags, rtx returnjump,
vec<edge> unconverted_simple_returns);
+/* In regcprop.c */
+extern void copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb);
#endif
#endif /* GCC_SHRINK_WRAP_H */
b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c
new file mode 100644
@@ -0,0 +1,20 @@
+/* { dg-do compile { target { { x86_64-*-* } || { arm_thumb2 } } } } */
+/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */
+
+int foo (int *p1, int *p2);
+
+int
+test (int *p1, int *p2)
+{
+ int *p;
+
+ for (p = p2; p != 0; p++)
+ {
+ if (!foo (p, p1))
+ return 0;
+ }
+
+ return 1;
+}
+/* { dg-final { scan-rtl-dump "Performing shrink-wrapping"
"pro_and_epilogue" } } */