From: Jiong Wang Date: Wed, 24 Sep 2014 18:30:34 +0000 (+0000) Subject: Improve prepare_shrink_wrap to sink more instructions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2b63a3acfa4f49c2117b1c03287be7b5df20ebf8;p=gcc.git Improve prepare_shrink_wrap to sink more instructions gcc/ * shrink-wrap.c (move_insn_for_shrink_wrap): Add further check when !REG_P (src) to release more instruction sink opportunities. gcc/testsuite/ * gcc.target/aarch64/shrink_wrap_symbol_ref_1.c: New testcase. From-SVN: r215563 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ce6738c852d..fd6a7d32cb6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-09-24 Jiong Wang + + * shrink-wrap.c (move_insn_for_shrink_wrap): Add further check when + !REG_P (src) to release more instruction sink opportunities. + 2014-09-24 Wilco Dijkstra * config/aarch64/aarch64.c (aarch64_register_move_cost): Add register diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c index 9ae8a08ec10..af23f0288d7 100644 --- a/gcc/shrink-wrap.c +++ b/gcc/shrink-wrap.c @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "bb-reorder.h" #include "shrink-wrap.h" #include "regcprop.h" +#include "rtl-iter.h" #ifdef HAVE_simple_return @@ -169,7 +170,9 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn, { rtx set, src, dest; bitmap live_out, live_in, bb_uses, bb_defs; - unsigned int i, dregno, end_dregno, sregno, end_sregno; + unsigned int i, dregno, end_dregno; + unsigned int sregno = FIRST_PSEUDO_REGISTER; + unsigned int end_sregno = FIRST_PSEUDO_REGISTER; basic_block next_block; edge live_edge; @@ -179,7 +182,34 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn, return false; src = SET_SRC (set); dest = SET_DEST (set); - if (!REG_P (dest) || !REG_P (src) + + if (!REG_P (src)) + { + unsigned int reg_num = 0; + unsigned int nonconstobj_num = 0; + rtx src_inner = NULL_RTX; + + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, src, ALL) + { + rtx x = *iter; + if (REG_P (x)) + { + reg_num++; + src_inner = x; + } + else if (!CONSTANT_P (x) && OBJECT_P (x)) + nonconstobj_num++; + } + + if (nonconstobj_num > 0 + || reg_num > 1) + src = NULL_RTX; + else if (reg_num == 1) + src = src_inner; + } + + if (!REG_P (dest) || src == NULL_RTX /* STACK or FRAME related adjustment might be part of prologue. So keep them in the entry block. */ || dest == stack_pointer_rtx @@ -188,10 +218,13 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn, return false; /* Make sure that the source register isn't defined later in BB. */ - sregno = REGNO (src); - end_sregno = END_REGNO (src); - if (overlaps_hard_reg_set_p (defs, GET_MODE (src), sregno)) - return false; + if (REG_P (src)) + { + sregno = REGNO (src); + end_sregno = END_REGNO (src); + if (overlaps_hard_reg_set_p (defs, GET_MODE (src), sregno)) + return false; + } /* Make sure that the destination register isn't referenced later in BB. */ dregno = REGNO (dest); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2b4f867fe5d..ddf0c323a04 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-09-24 Jiong Wang + + * gcc.target/aarch64/shrink_wrap_symbol_ref_1.c: New testcase. + 2014-09-24 Marek Polacek PR c/61405 diff --git a/gcc/testsuite/gcc.target/aarch64/shrink_wrap_symbol_ref_1.c b/gcc/testsuite/gcc.target/aarch64/shrink_wrap_symbol_ref_1.c new file mode 100644 index 00000000000..dd3056d0aac --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/shrink_wrap_symbol_ref_1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */ + +extern char *asm_out_file; +extern void default_elf_asm_output_ascii (char *, const char *, int); + +void +assemble_string (const char *p, int size) +{ + int pos = 0; + int maximum = 2000; + + while (pos < size) + { + int thissize = size - pos; + + if (thissize > maximum) + thissize = maximum; + + default_elf_asm_output_ascii (asm_out_file, p, thissize);; + + pos += thissize; + p += thissize; + } +} + +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" } } */ +/* { dg-final { cleanup-rtl-dump "pro_and_epilogue" } } */