aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorZhenqiang Chen <zhenqiang.chen@linaro.org>2014-05-15 06:54:48 +0000
committerZhenqiang Chen <zqchen@gcc.gnu.org>2014-05-15 06:54:48 +0000
commita2e6c10cbd7ff6f51052d5a550b4bf999189aa31 (patch)
tree7b099524607ef851d55ab807f10d94713196c9d1 /gcc
parente974b93b6cb75eb6828918fb4bb8454ed8249096 (diff)
downloadgcc-a2e6c10cbd7ff6f51052d5a550b4bf999189aa31.zip
gcc-a2e6c10cbd7ff6f51052d5a550b4bf999189aa31.tar.gz
gcc-a2e6c10cbd7ff6f51052d5a550b4bf999189aa31.tar.bz2
regcprop.h: New file.
2014-05-15 Zhenqiang Chen <zhenqiang.chen@linaro.org> * regcprop.h: New file. * regcprop.c (skip_debug_insn_p): New decl. (replace_oldest_value_reg): Check skip_debug_insn_p. (copyprop_hardreg_forward_bb_without_debug_insn.): New function. * shrink-wrap.c: include regcprop.h (prepare_shrink_wrap): Call copyprop_hardreg_forward_bb_without_debug_insn. testsuite/ChangeLog: 2014-05-15 Zhenqiang Chen <zhenqiang.chen@linaro.org> * shrink-wrap-loop.c: New test case. From-SVN: r210458
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/regcprop.c23
-rw-r--r--gcc/regcprop.h27
-rw-r--r--gcc/shrink-wrap.c11
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/shrink-wrap-loop.c20
6 files changed, 93 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index daf1d6c..beac3a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
2014-05-15 Zhenqiang Chen <zhenqiang.chen@linaro.org>
+ * regcprop.h: New file.
+ * regcprop.c (skip_debug_insn_p): New decl.
+ (replace_oldest_value_reg): Check skip_debug_insn_p.
+ (copyprop_hardreg_forward_bb_without_debug_insn.): New function.
+ * shrink-wrap.c: include regcprop.h
+ (prepare_shrink_wrap):
+ Call copyprop_hardreg_forward_bb_without_debug_insn.
+
+2014-05-15 Zhenqiang Chen <zhenqiang.chen@linaro.org>
+
* shrink-wrap.h: Update comment.
* shrink-wrap.c: Update comment.
(next_block_for_reg): Rename to live_edge_for_reg.
diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index a710cc38..7a5a4f6 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -77,6 +77,7 @@ struct value_data
};
static alloc_pool debug_insn_changes_pool;
+static bool skip_debug_insn_p;
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)
diff --git a/gcc/regcprop.h b/gcc/regcprop.h
new file mode 100644
index 0000000..ab54eaf
--- /dev/null
+++ b/gcc/regcprop.h
@@ -0,0 +1,27 @@
+/* Copy propagation on hard registers.
+ Copyright (C) 1989-2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_REGCPROP_H
+#define GCC_REGCPROP_H
+
+#include "basic-block.h"
+
+extern void copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb);
+
+#endif /* GCC_REGCPROP_H */
diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index 6f0cd0c..f09cfe7 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -52,7 +52,7 @@ along with GCC; see the file COPYING3. If not see
#include "params.h"
#include "bb-reorder.h"
#include "shrink-wrap.h"
-
+#include "regcprop.h"
#ifdef HAVE_simple_return
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fa968bf..7df284e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-05-15 Zhenqiang Chen <zhenqiang.chen@linaro.org>
+
+ * shrink-wrap-loop.c: New test case.
+
2014-05-14 Alan Lawrence <alan.lawrence@arm.com>
* gcc.target/arm/simd/vtrnqf32_1.c: New file.
diff --git a/gcc/testsuite/gcc.dg/shrink-wrap-loop.c b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c
new file mode 100644
index 0000000..17dca4e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c
@@ -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" } } */
+/* { dg-final { cleanup-rtl-dump "pro_and_epilogue" } } */