From: Oleg Endo Date: Wed, 7 May 2014 20:08:23 +0000 (+0000) Subject: re PR target/60884 ([SH] improve inlined strlen-like builtin functions) X-Git-Tag: releases/gcc-5.1.0~7723 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=36dc9ae8cdee7cb96bb5f04c07c73c4dd5dc13e0;p=thirdparty%2Fgcc.git re PR target/60884 ([SH] improve inlined strlen-like builtin functions) gcc/ PR target/60884 * config/sh/sh-mem.cc (sh_expand_strlen): Use loop when emitting unrolled byte insns. Emit address increments after move insns. gcc/testsuite/ PR target/60884 * gcc.target/sh/pr53976-1.c (test_02): Remove inappropriate test case. (test_03): Rename to test_02. From-SVN: r210187 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 67d5a9d691e4..2dde4fb1b66c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-05-07 Oleg Endo + + PR target/60884 + * config/sh/sh-mem.cc (sh_expand_strlen): Use loop when emitting + unrolled byte insns. Emit address increments after move insns. + 2014-05-07 David Malcolm * gimple.h (gimple_builtin_call_types_compatible_p): Accept a diff --git a/gcc/config/sh/sh-mem.cc b/gcc/config/sh/sh-mem.cc index 0e38913b929b..d3110f2351f3 100644 --- a/gcc/config/sh/sh-mem.cc +++ b/gcc/config/sh/sh-mem.cc @@ -568,7 +568,7 @@ sh_expand_strlen (rtx *operands) addr1 = adjust_automodify_address (addr1, SImode, current_addr, 0); - /*start long loop. */ + /* start long loop. */ emit_label (L_loop_long); /* tmp1 is aligned, OK to load. */ @@ -589,29 +589,15 @@ sh_expand_strlen (rtx *operands) addr1 = adjust_address (addr1, QImode, 0); /* unroll remaining bytes. */ - emit_insn (gen_extendqisi2 (tmp1, addr1)); - emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx)); - jump = emit_jump_insn (gen_branch_true (L_return)); - add_int_reg_note (jump, REG_BR_PROB, prob_likely); - - emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1)); - - emit_insn (gen_extendqisi2 (tmp1, addr1)); - emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx)); - jump = emit_jump_insn (gen_branch_true (L_return)); - add_int_reg_note (jump, REG_BR_PROB, prob_likely); - - emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1)); - - emit_insn (gen_extendqisi2 (tmp1, addr1)); - emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx)); - jump = emit_jump_insn (gen_branch_true (L_return)); - add_int_reg_note (jump, REG_BR_PROB, prob_likely); - - emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1)); + for (int i = 0; i < 4; ++i) + { + emit_insn (gen_extendqisi2 (tmp1, addr1)); + emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1)); + emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx)); + jump = emit_jump_insn (gen_branch_true (L_return)); + add_int_reg_note (jump, REG_BR_PROB, prob_likely); + } - emit_insn (gen_extendqisi2 (tmp1, addr1)); - jump = emit_jump_insn (gen_jump_compact (L_return)); emit_barrier_after (jump); /* start byte loop. */ @@ -626,10 +612,9 @@ sh_expand_strlen (rtx *operands) /* end loop. */ - emit_insn (gen_addsi3 (start_addr, start_addr, GEN_INT (1))); - emit_label (L_return); + emit_insn (gen_addsi3 (start_addr, start_addr, GEN_INT (1))); emit_insn (gen_subsi3 (operands[0], current_addr, start_addr)); return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b4ef30a8d1e..123a02f0378c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-05-07 Oleg Endo + + PR target/60884 + * gcc.target/sh/pr53976-1.c (test_02): Remove inappropriate test case. + (test_03): Rename to test_02. + 2014-05-07 Paolo Carlini PR c++/61083 diff --git a/gcc/testsuite/gcc.target/sh/pr53976-1.c b/gcc/testsuite/gcc.target/sh/pr53976-1.c index 4893b0668a5e..68f8cdcc4307 100644 --- a/gcc/testsuite/gcc.target/sh/pr53976-1.c +++ b/gcc/testsuite/gcc.target/sh/pr53976-1.c @@ -24,14 +24,7 @@ test_01 (long long a, long long b) } int -test_02 (const char* a) -{ - /* Must not see a sett after the inlined strlen. */ - return __builtin_strlen (a); -} - -int -test_03 (int a, int b, int c, int d) +test_02 (int a, int b, int c, int d) { /* One of the blocks should have a sett and the other one should not. */ if (d > 4)