diff options
author | David Sherwood <david.sherwood@arm.com> | 2015-05-19 17:37:45 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2015-05-19 11:37:45 -0600 |
commit | 315a349c27e1395a9bde30876824891027e67aac (patch) | |
tree | 4a838115d14ebe93303016d8ff822904c206b25c /gcc | |
parent | 0aaaa54a73ed57a95e13403158e345f7bab01ff9 (diff) | |
download | gcc-315a349c27e1395a9bde30876824891027e67aac.zip gcc-315a349c27e1395a9bde30876824891027e67aac.tar.gz gcc-315a349c27e1395a9bde30876824891027e67aac.tar.bz2 |
loop-invariant.c (create_new_invariant): Don't calculate address cost if mode is not a scalar integer.
2015-05-19 David Sherwood <david.sherwood@arm.com>
* loop-invariant.c (create_new_invariant): Don't calculate address cost
if mode is not a scalar integer.
(get_inv_cost): Increase computational cost for unused invariants.
* gcc.dg/loop-invariant.c: New testcase.
From-SVN: r223402
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/loop-invariant.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/loop-invariant.c | 43 |
4 files changed, 59 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2726dbf..fcde743 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-05-19 David Sherwood <david.sherwood@arm.com> + + * loop-invariant.c (create_new_invariant): Don't calculate address cost + if mode is not a scalar integer. + (get_inv_cost): Increase computational cost for unused invariants. + 2015-05-19 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * config.gcc: Add vecintrin.h to extra_headers. Add s390-c.o to diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 1c3eae5..85270fe 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -741,8 +741,11 @@ create_new_invariant (struct def *def, rtx_insn *insn, bitmap depends_on, enough to not regress 410.bwaves either (by still moving reg+reg invariants). See http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01210.html . */ - inv->cheap_address = address_cost (SET_SRC (set), word_mode, - ADDR_SPACE_GENERIC, speed) < 3; + if (SCALAR_INT_MODE_P (GET_MODE (SET_DEST (set)))) + inv->cheap_address = address_cost (SET_SRC (set), word_mode, + ADDR_SPACE_GENERIC, speed) < 3; + else + inv->cheap_address = false; } else { @@ -1173,6 +1176,7 @@ get_inv_cost (struct invariant *inv, int *comp_cost, unsigned *regs_needed, } if (!inv->cheap_address + || inv->def->n_uses == 0 || inv->def->n_addr_uses < inv->def->n_uses) (*comp_cost) += inv->cost * inv->eqno; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 27313a41..1b9a956 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-05-19 David Sherwood <david.sherwood@arm.com> + + * gcc.dg/loop-invariant.c: New testcase. + 2015-05-19 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * gcc.dg/tree-ssa/gen-vect-11b.c: Disable vector instructions on diff --git a/gcc/testsuite/gcc.dg/loop-invariant.c b/gcc/testsuite/gcc.dg/loop-invariant.c new file mode 100644 index 0000000..9571269 --- /dev/null +++ b/gcc/testsuite/gcc.dg/loop-invariant.c @@ -0,0 +1,43 @@ +/* { dg-do compile { target x86_64-*-* } } */ +/* { dg-options "-O2 -fdump-rtl-loop2_invariant" } */ +/* NOTE: The target list above could be extended to other targets that have + conditional moves, but don't have zero registers. */ + +enum test_type +{ + TYPE0, + TYPE1 +}; + +struct type_node +{ + enum test_type type; +}; + +struct test_ref +{ + struct type_node *referring; +}; + +struct test_node +{ + struct test_node *next; +}; + +int iterate (struct test_node *, unsigned, struct test_ref **); + +int +loop_invar (struct test_node *node) +{ + struct test_ref *ref; + + for (unsigned i = 0; iterate (node, i, &ref); i++) + if (loop_invar ((ref->referring && ref->referring->type == TYPE0) + ? ((struct test_node *) (ref->referring)) : 0)) + return 1; + + return 0; +} + +/* { dg-final { scan-rtl-dump "Decided to move invariant" "loop2_invariant" } } */ +/* { dg-final { cleanup-rtl-dump "loop2_invariant" } } */ |