OSDN Git Service

PR target/41514
authorbernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2010 09:42:32 +0000 (09:42 +0000)
committerbernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2010 09:42:32 +0000 (09:42 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158404 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/arm/arm.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/thumb-comparisons.c [new file with mode: 0644]

index 79f4c59..0e384b5 100644 (file)
@@ -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,
index c5e2a16..1a07f36 100644 (file)
                                   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")
              (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))
     {
index a029d98..3f0fe2b 100644 (file)
@@ -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 (file)
index 0000000..45be2cf
--- /dev/null
@@ -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 } } */