aboutsummaryrefslogtreecommitdiff
path: root/gcc/cprop.c
diff options
context:
space:
mode:
authorKugan Vivekanandarajah <kuganv@linaro.org>2015-06-02 22:53:15 +0000
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>2015-06-02 22:53:15 +0000
commit32e0a7d983cd3076bbdff448e583773ee4081a37 (patch)
treeaa3f931c05cc63c4985ddf3fb2069f2f31bb9393 /gcc/cprop.c
parent2b263f6a0133495b978ef20aead430854e5aa538 (diff)
downloadgcc-32e0a7d983cd3076bbdff448e583773ee4081a37.zip
gcc-32e0a7d983cd3076bbdff448e583773ee4081a37.tar.gz
gcc-32e0a7d983cd3076bbdff448e583773ee4081a37.tar.bz2
re PR target/65768 (sub-optimimal code for constant Uses in loop)
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. Co-Authored-By: Zhenqiang Chen <zhenqiang.chen@linaro.org> From-SVN: r224048
Diffstat (limited to 'gcc/cprop.c')
-rw-r--r--gcc/cprop.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cprop.c b/gcc/cprop.c
index 41ca201..6a756f3 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;