ifcvt.c (noce_try_store_flag_mask): Check rtx cost.
authorZhenqiang Chen <zhenqiang.chen@arm.com>
Mon, 3 Nov 2014 06:36:11 +0000 (06:36 +0000)
committerZhenqiang Chen <zqchen@gcc.gnu.org>
Mon, 3 Nov 2014 06:36:11 +0000 (06:36 +0000)
ChangeLog:
2014-11-03  Zhenqiang Chen  <zhenqiang.chen@arm.com>

* ifcvt.c (noce_try_store_flag_mask): Check rtx cost.

testsuite/ChangeLog:
2014-11-03  Zhenqiang Chen  <zhenqiang.chen@arm.com>

* gcc.target/arm/ifcvt-size-check.c: New test.

From-SVN: r217029

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/ifcvt-size-check.c [new file with mode: 0644]

index 116bc37660cc8fb579fd037a71f881598f1ed993..bcfbd9b44abda2db2a6bf4e06b94fe934d834710 100644 (file)
@@ -1,3 +1,7 @@
+2014-11-03  Zhenqiang Chen  <zhenqiang.chen@arm.com>
+
+       * ifcvt.c (noce_try_store_flag_mask): Check rtx cost.
+
 2014-11-03  Andrew Pinski  <apinski@cavium.com>
 
        * config/mips/mips-cpus.def (octeon3): New cpu.
index f8ea467111b2c6b1a1d29082cf21e5a26732eb97..c5a104e2b6d07b97e95a0f322b17022cc8869268 100644 (file)
@@ -1394,6 +1394,9 @@ noce_try_store_flag_mask (struct noce_if_info *if_info)
 
       if (target)
        {
+         int old_cost, new_cost, insn_cost;
+         int speed_p;
+
          if (target != if_info->x)
            noce_emit_move_insn (if_info->x, target);
 
@@ -1401,6 +1404,14 @@ noce_try_store_flag_mask (struct noce_if_info *if_info)
          if (!seq)
            return FALSE;
 
+         speed_p = optimize_bb_for_speed_p (BLOCK_FOR_INSN (if_info->insn_a));
+         insn_cost = insn_rtx_cost (PATTERN (if_info->insn_a), speed_p);
+         old_cost = COSTS_N_INSNS (if_info->branch_cost) + insn_cost;
+         new_cost = seq_cost (seq, speed_p);
+
+         if (new_cost > old_cost)
+           return FALSE;
+
          emit_insn_before_setloc (seq, if_info->jump,
                                   INSN_LOCATION (if_info->insn_a));
          return TRUE;
index 967ccb9df09f999401efcb9a02dbe0ac3ebec1b1..1bf0c07c8d180f867b8da2146f2367e498645774 100644 (file)
@@ -1,3 +1,7 @@
+2014-11-03  Zhenqiang Chen  <zhenqiang.chen@arm.com>
+
+       * gcc.target/arm/ifcvt-size-check.c: New test.
+
 2014-11-03  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
        * gcc.target/mips/octeon3-pipe-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c b/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c
new file mode 100644 (file)
index 0000000..43fa16b
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do assemble } */
+/* { dg-options "-mthumb -Os " }  */
+/* { dg-require-effective-target arm_thumb1_ok } */
+
+int
+test (unsigned char iov_len, int count, int i)
+{
+  unsigned char bytes = 0;
+  if ((unsigned char) ((char) 127 - bytes) < iov_len)
+    return 22;
+  return 0;
+}
+/* { dg-final { object-size text <= 12 } } */