]> gcc.gnu.org Git - gcc.git/commitdiff
re PR target/65768 (sub-optimimal code for constant Uses in loop)
authorKugan Vivekanandarajah <kuganv@linaro.org>
Tue, 2 Jun 2015 22:53:15 +0000 (22:53 +0000)
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>
Tue, 2 Jun 2015 22:53:15 +0000 (22:53 +0000)
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

gcc/ChangeLog
gcc/cprop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/maskdata.c

index fc87c1861484e4962d2597cb7ff7a1cfa5a67966..d1e55c74e1f33883c957f58090622b6a68753533 100644 (file)
@@ -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
index 41ca20124edd418f59a6a458ebee7085338f9f83..6a756f3fceda8f0a945dd02b6249420d5d2f6840 100644 (file)
@@ -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;
 
index 1b3126d4fa6e83e44dbc54eecb15e4baf55bfacd..9175014001db62ff47279a1d560a3634725a4082 100644 (file)
@@ -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
index 6d6bb39a2655de17a7b944bbf60f275e7772a4ec..35d2f060d10850c5b50b68e5b597e3d7893bad7d 100644 (file)
@@ -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
This page took 0.087814 seconds and 5 git commands to generate.