diff options
author | Bernd Schmidt <bernd.schmidt@codesourcery.com> | 2010-04-16 09:42:32 +0000 |
---|---|---|
committer | Bernd Schmidt <bernds@gcc.gnu.org> | 2010-04-16 09:42:32 +0000 |
commit | 6ea007e447876a49b7ea271d0bdee721e6b98cef (patch) | |
tree | 9049fc03e8bcf8a31faf13f9fdffe9a4b1fdf3c3 /gcc | |
parent | 6ddfdb0f7e310a026479c484e32d020b1cbeedf8 (diff) | |
download | gcc-6ea007e447876a49b7ea271d0bdee721e6b98cef.zip gcc-6ea007e447876a49b7ea271d0bdee721e6b98cef.tar.gz gcc-6ea007e447876a49b7ea271d0bdee721e6b98cef.tar.bz2 |
re PR target/41514 (redundant compare instruction of consecutive conditional branches)
PR target/41514
* config/arm/arm.md (cbranchsi4_insn): Renamed from "*cbranchsi4_insn".
If the previous insn is a cbranchsi4_insn with the same arguments,
omit the compare instruction.
PR target/41514
gcc.target/arm/thumb-comparisons.c: New test.
From-SVN: r158404
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/config/arm/arm.md | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arm/thumb-comparisons.c | 18 |
4 files changed, 43 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 79f4c59..0e384b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -8,6 +8,11 @@ * reload.c (find_reloads): Use it rather than testing for an empty constraint string. + PR target/41514 + * config/arm/arm.md (cbranchsi4_insn): Renamed from "*cbranchsi4_insn". + If the previous insn is a cbranchsi4_insn with the same arguments, + omit the compare instruction. + 2010-04-16 Jakub Jelinek <jakub@redhat.com> * alias.c (memrefs_conflict_p): If x and y are the same VALUE, diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index c5e2a16..1a07f36 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -6705,7 +6705,7 @@ operands[3])); DONE;" ) -(define_insn "*cbranchsi4_insn" +(define_insn "cbranchsi4_insn" [(set (pc) (if_then_else (match_operator 0 "arm_comparison_operator" [(match_operand:SI 1 "s_register_operand" "l,*h") @@ -6714,7 +6714,20 @@ (pc)))] "TARGET_THUMB1" "* - output_asm_insn (\"cmp\\t%1, %2\", operands); + rtx t = prev_nonnote_insn (insn); + if (t != NULL_RTX + && INSN_P (t) + && INSN_CODE (t) == CODE_FOR_cbranchsi4_insn) + { + t = XEXP (SET_SRC (PATTERN (t)), 0); + if (!rtx_equal_p (XEXP (t, 0), operands[1]) + || !rtx_equal_p (XEXP (t, 1), operands[2])) + t = NULL_RTX; + } + else + t = NULL_RTX; + if (t == NULL_RTX) + output_asm_insn (\"cmp\\t%1, %2\", operands); switch (get_attr_length (insn)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a029d98..3f0fe2b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-16 Bernd Schmidt <bernd.schmidt@codesourcery.com> + + PR target/41514 + gcc.target/arm/thumb-comparisons.c: New test. + 2010-04-16 Christian Bruel <christian.bruel@st.com> * g++.dg/torture/pr36191.C: Enable for SH. diff --git a/gcc/testsuite/gcc.target/arm/thumb-comparisons.c b/gcc/testsuite/gcc.target/arm/thumb-comparisons.c new file mode 100644 index 0000000..45be2cf --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/thumb-comparisons.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-mthumb -Os" } */ +/* { dg-require-effective-target arm_thumb1_ok } */ + +int foo(char ch) +{ + switch (ch) { + case '-': + case '?': + case '/': + case 99: + return 1; + default: + return 0; + } +} + +/* { dg-final { scan-assembler-times "cmp\[\\t \]*r.,\[\\t \]*#63" 1 } } */ |