OSDN Git Service

PR target/40603
authorbernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2010 10:04:15 +0000 (10:04 +0000)
committerbernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Apr 2010 10:04:15 +0000 (10:04 +0000)
* config/arm/arm.md (cbranchqi4): New pattern.
* config/arm/predicates.md (const0_operand,
cbranchqi4_comparison_operator): New predicates.

PR target/40603
* gcc.target/arm/thumb-cbranchqi.c: New test.

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

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

index bca40b7..38952fc 100644 (file)
@@ -1,9 +1,16 @@
+2010-04-16  Bernd Schmidt  <bernds@codesourcery.com>
+
+       PR target/40603
+       * config/arm/arm.md (cbranchqi4): New pattern.
+       * config/arm/predicates.md (const0_operand,
+       cbranchqi4_comparison_operator): New predicates.
+
 2010-04-16  Richard Guenther  <rguenther@suse.de>
 
        * gimple-pretty-print.c (dump_gimple_phi): Dump alias info.
        (dump_gimple_stmt): Likewise.
 
-2010-04-16  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-04-16  Bernd Schmidt  <bernds@codesourcery.com>
 
        * recog.h (struct recog_data): New field is_operator.
        (struct insn_operand_data): New field is_operator.
        div_and_round_double): Move prototypes ...
        * double-int.h: ... here.
 
-2010-04-15  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-04-15  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR target/43742
        * config/sh/sh.md (doloop_end_split, dect): Undo previous patch.  Use
        comment.
        * expmed.c (mask_rtx, lshift_value): (Ditto.).
 
-2010-04-14  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-04-14  Bernd Schmidt  <bernds@codesourcery.com>
        
        PR target/21803
        * ifcvt.c (cond_exec_process_if_block): Look for identical sequences
        (arm_output_addr_const_extra): Output expression for new pattern.
        * config/arm/arm.md (UNSPEC_SYMBOL_OFFSET): New unspec symbol.
 
-2010-04-10  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-04-10  Bernd Schmidt  <bernds@codesourcery.com>
 
        * ira-costs.c (record_reg_classes): Ignore alternatives that are
        not enabled.
        * ipa-prop.c (ipa_print_node_jump_functions): Likewise.
 
 2010-04-09  Eric Botcazou  <ebotcazou@adacore.com>
-           Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+           Bernd Schmidt  <bernds@codesourcery.com>
 
        * loop-invariant.c (replace_uses): New static function.
        (move_invariant_reg): Use it to ensure we can replace the uses.
        * c-decl.c (grokparms): Set arg_types to NULL_TREE if there was
        an error.
 
-2010-03-19  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-03-19  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR rtl-optimization/42258
        * ira-lives.c (check_and_make_def_conflict): Ignore conflict for a
index 4604e13..fb9c024 100644 (file)
     operands[2] = force_reg (SImode, operands[2]);
   ")
 
+;; A pattern to recognize a special situation and optimize for it.
+;; On the thumb, zero-extension from memory is preferrable to sign-extension
+;; due to the available addressing modes.  Hence, convert a signed comparison
+;; with zero into an unsigned comparison with 127 if possible.
+(define_expand "cbranchqi4"
+  [(set (pc) (if_then_else
+             (match_operator 0 "lt_ge_comparison_operator"
+              [(match_operand:QI 1 "memory_operand" "")
+               (match_operand:QI 2 "const0_operand" "")])
+             (label_ref (match_operand 3 "" ""))
+             (pc)))]
+  "TARGET_THUMB1"
+{
+  rtx xops[3];
+  xops[1] = gen_reg_rtx (SImode);
+  emit_insn (gen_zero_extendqisi2 (xops[1], operands[1]));
+  xops[2] = GEN_INT (127);
+  xops[0] = gen_rtx_fmt_ee (GET_CODE (operands[0]) == GE ? LEU : GTU,
+                           VOIDmode, xops[1], xops[2]);
+  xops[3] = operands[3];
+  emit_insn (gen_cbranchsi4 (xops[0], xops[1], xops[2], xops[3]));
+  DONE;
+})
+
 (define_expand "cbranchsf4"
   [(set (pc) (if_then_else
              (match_operator 0 "arm_comparison_operator"
index d351f44..a60da9a 100644 (file)
   (and (match_code "const_int")
        (match_test "const_ok_for_arm (~INTVAL (op))")))
 
+(define_predicate "const0_operand"
+  (and (match_code "const_int")
+       (match_test "INTVAL (op) == 0")))
+
 ;; Something valid on the RHS of an ARM data-processing instruction
 (define_predicate "arm_rhs_operand"
   (ior (match_operand 0 "s_register_operand")
                         && (TARGET_FPA || TARGET_VFP)")
             (match_code "unordered,ordered,unlt,unle,unge,ungt"))))
 
+(define_special_predicate "lt_ge_comparison_operator"
+  (match_code "lt,ge"))
+
 (define_special_predicate "minmax_operator"
   (and (match_code "smin,smax,umin,umax")
        (match_test "mode == GET_MODE (op)")))
index 3f0fe2b..450aa4f 100644 (file)
@@ -1,7 +1,10 @@
-2010-04-16  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-04-16  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR target/41514
-       gcc.target/arm/thumb-comparisons.c: New test.
+       * gcc.target/arm/thumb-comparisons.c: New test.
+
+       PR target/40603
+       * gcc.target/arm/thumb-cbranchqi.c: New test.
 
 2010-04-16  Christian Bruel  <christian.bruel@st.com>
 
@@ -30,7 +33,7 @@
        * gcc.dg/torture/ipa-pta-2.c: Likewise.
        * gcc.dg/torture/ipa-pta-1.c: Adjust.
 
-2010-04-14  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-04-14  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR target/21803
        * gcc.target/arm/pr42496.c: New test.
        * gcc.dg/pr43211.c: New test.
        * gcc.dg/pr18809-1.c: Don't expect an error when calling foo.
 
-2010-03-19  Bernd Schmidt  <bernd.schmidt@codesourcery.com>
+2010-03-19  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR rtl-optimization/42258
        * gcc.target/arm/thumb1-mul-moves.c: New test.
diff --git a/gcc/testsuite/gcc.target/arm/thumb-cbranchqi.c b/gcc/testsuite/gcc.target/arm/thumb-cbranchqi.c
new file mode 100644 (file)
index 0000000..ad28e7f
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mthumb -Os" }  */
+/* { dg-require-effective-target arm_thumb1_ok } */
+
+int ldrb(unsigned char* p)
+{
+  if (p[8] <= 0x7F)
+    return 2;
+  else
+    return 5;
+}
+
+
+/* { dg-final { scan-assembler "127" } } */
+/* { dg-final { scan-assembler "bhi" } } */