From b5a4533b365b1405a3649f2f7c135ade80917e7b Mon Sep 17 00:00:00 2001 From: Zhenqiang Chen Date: Mon, 3 Nov 2014 06:36:11 +0000 Subject: [PATCH] ifcvt.c (noce_try_store_flag_mask): Check rtx cost. ChangeLog: 2014-11-03 Zhenqiang Chen * ifcvt.c (noce_try_store_flag_mask): Check rtx cost. testsuite/ChangeLog: 2014-11-03 Zhenqiang Chen * gcc.target/arm/ifcvt-size-check.c: New test. From-SVN: r217029 --- gcc/ChangeLog | 4 ++++ gcc/ifcvt.c | 11 +++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/arm/ifcvt-size-check.c | 13 +++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/ifcvt-size-check.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 116bc37660c..bcfbd9b44ab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-11-03 Zhenqiang Chen + + * ifcvt.c (noce_try_store_flag_mask): Check rtx cost. + 2014-11-03 Andrew Pinski * config/mips/mips-cpus.def (octeon3): New cpu. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index f8ea467111b..c5a104e2b6d 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 967ccb9df09..1bf0c07c8d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-11-03 Zhenqiang Chen + + * gcc.target/arm/ifcvt-size-check.c: New test. + 2014-11-03 Naveen H.S * 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 index 00000000000..43fa16b82b5 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c @@ -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 } } */ -- 2.30.2