summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkugan <kugan@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-02 22:53:15 +0000
committerkugan <kugan@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-02 22:53:15 +0000
commita19b6344800f6faef095c6aa3b0c7bef5e29b2fc (patch)
treeaa3f931c05cc63c4985ddf3fb2069f2f31bb9393
parent12e011e3ae973e616737f448a0412fbf1b52424f (diff)
downloadgcc-a19b6344800f6faef095c6aa3b0c7bef5e29b2fc.tar.gz
gcc/ChangeLog:
2015-06-03 Kugan Vivekanandarajah <kuganv@linaro.org> Zhenqiang Chen <zhenqiang.chen@linaro.org> PR target/65768 * cprop.c (try_replace_reg): Check cost of constants before propagating. gcc/testsuite/ChangeLog: 2015-06-03 Kugan Vivekanandarajah <kuganv@linaro.org> PR target/65768 * gcc.target/arm/maskdata.c: Remove -fno-gcse. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224048 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cprop.c25
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/arm/maskdata.c2
4 files changed, 37 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fc87c186148..d1e55c74e1f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-03 Kugan Vivekanandarajah <kuganv@linaro.org>
+ Zhenqiang Chen <zhenqiang.chen@linaro.org>
+
+ PR target/65768
+ * cprop.c (try_replace_reg): Check cost of constants before propagating.
+
2015-06-02 Michael Meissner <meissner@linux.vnet.ibm.com>
* config/rs6000/rs6000-modes.def (IFmode): Define IFmode to
diff --git a/gcc/cprop.c b/gcc/cprop.c
index 41ca20124ed..6a756f3fced 100644
--- a/gcc/cprop.c
+++ b/gcc/cprop.c
@@ -766,12 +766,37 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
int success = 0;
rtx set = single_set (insn);
+ bool check_rtx_costs = true;
+ bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn));
+ int old_cost = set ? set_rtx_cost (set, speed) : 0;
+
+ if ((note != 0
+ && REG_NOTE_KIND (note) == REG_EQUAL
+ && (GET_CODE (XEXP (note, 0)) == CONST
+ || CONSTANT_P (XEXP (note, 0))))
+ || (set && CONSTANT_P (SET_SRC (set))))
+ check_rtx_costs = false;
+
/* Usually we substitute easy stuff, so we won't copy everything.
We however need to take care to not duplicate non-trivial CONST
expressions. */
to = copy_rtx (to);
validate_replace_src_group (from, to, insn);
+
+ /* If TO is a constant, check the cost of the set after propagation
+ to the cost of the set before the propagation. If the cost is
+ higher, then do not replace FROM with TO. */
+
+ if (check_rtx_costs
+ && CONSTANT_P (to)
+ && (set_rtx_cost (set, speed) > old_cost))
+ {
+ cancel_changes (0);
+ return false;
+ }
+
+
if (num_changes_pending () && apply_change_group ())
success = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1b3126d4fa6..9175014001d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-01 Kugan Vivekanandarajah <kuganv@linaro.org>
+
+ PR target/65768
+ * gcc.target/arm/maskdata.c: Remove -fno-gcse.
+
2015-06-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66380
diff --git a/gcc/testsuite/gcc.target/arm/maskdata.c b/gcc/testsuite/gcc.target/arm/maskdata.c
index 6d6bb39a265..35d2f060d10 100644
--- a/gcc/testsuite/gcc.target/arm/maskdata.c
+++ b/gcc/testsuite/gcc.target/arm/maskdata.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options " -O2 -fno-gcse " } */
+/* { dg-options " -O2" } */
/* { dg-require-effective-target arm_thumb2_ok } */
#define MASK 0xff00ff